Hi,
I'm trying to debug a
servlet and
jsp page at work and need a little help, not having much experience in this field. I have tried to be concise and put 3 questions at the end which would help me if they were answered!!
What happens is this: the user clicks a html form button on a jsp page. This is posted to a servlet. The servlet then stores a session variable and dispatches the request to another jsp page, which obtains the session variable. Like this:
/* In doPost method of servlet */
Integer i = new Integer (22);
request.setAttribute ("value", i);
//now uses a request dispatcher and dispatches to another jsp page
/* in other jsp page */
<%
Integer i = session.getAttribute ("value");
%>
The problem i'm having is that I am getting the appserver giving me a compile error at runtime saying that 'session' is a variable which cannot be identified in the jsp page. I cannot understand this, I thought it was implicitly accessible.
1) Do I have to put a particular page directive at the top of my jsp file to allow the jsp to access the "session" object?
2) Should my servlet be putting an attribute in the session or the request object?
3) If there is a <useBean> tag at the top of the page, and the 'id' of that tag is set to the name of a session variable (and the type matches, too) does this mean that one can directly access the variable using the 'id' name. e.g:
//assume there is a session variable of type
String called "name"
<jsp:useBean id="name" class="java.lang.String"/>
<%= name %>
will this work and print out the String?
many thanks!
john