Hi Gael,
When you author JSPs, you have access to certain implicit objects that
are
always available for use within scriptlets and expressions, without
being
declared first.
'session' *is* an implicit variable of type
javax.servlet.http.HttpSession.
Note it is a fatal translation error to attempt to use session scope
when the
JSP so attempting has declared, via the <%@ page ... %> directive that
it does
not participate in a session.
ie if your page directive declares as shown,
<%@ page language="java" import="com.mypac.*" session="false"
buffer="16k" %>
then, the page does not participate in a session; the "session" implicit
variable is unavailable, and any reference to it within the body of the
JSP is
illegal and shall result in a fatal translation error. Default is
"true".
So, if the session is true then your scriplet can directly access the
session
variable as shown.
<%
Vector myItems = (Vector) session.getValue("ecom.myShoppingCart");
if (buylist != null && (buylist.size() > 0)) {
%>
Hope this helps.
-Kiran.
Gael Stehagen wrote:
> I get a perculiar error, when executing a jsp-page on Tomcat3.1.
> I can't create a session if I try to name it session like this:
>
> <%
> HttpSession session = request.getSession();
> System.out.println("Session Id: " + session.getId();)
> %>
>
> When I access my page from Tomcat, freshly restarted and emptied on all
> caches, I get the message:
> _______
> org.apache.jasper.JasperException: Unable to compile class for
> JSPwork/localhost_8080%2FCIA/_0002findex_0002ejspindex_jsp_138.java:90:
> Variable 'session' is already defined in this method.
> HttpSession session = request.getSession();
> ^
> 1 error
> _______
>
> I'm certain that I haven't created a session before!
> Where does this come from?
> If I remove "my" session, I do get a Id, from the ghost-session, so
> obviously it exists...
>
> Can anyone shed some light over this?
> /G
>
> O--
> ************************
> Gael Stehagen
> [EMAIL PROTECTED]
> 0708-882910
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html