Forums Register Login

session.setAttribute() not working

+Pie Number of slices to send: Send
file name GetName.html
<html>
<body>
<FORM METHOD = POST ACTION = "SaveName.jsp">
what is your name?
<INPUT TYPE = TEXT NAME=username SIZE= 20>
<p><INPUT TYPE= SUBMIT>
</FORM>
</BODY>
</HTML>
file name SaveName.jsp
<%
String name = request.getParameter( "username" );
session.setAttribute( "theName", name );
%>
<HTML>
<BODY>
<A HREF="NextPage.jsp">Continue</A>
</BODY>
</HTML>
file name NextPage.jsp
<html>
<body>
Hello, <%=session.getAttribute("theName") %>
</body>
</html>
when I try to execute , SaveName.jsp is generating the following error message. what is the problem? I am using jswdk. please help.
Unhandled error! You might want to consider having an error page to report such
errors more gracefully
com.sun.jsp.JspException: Compilation failed:work\%3A8080%2Fexamples\jsp_0005cmy
files_0005cSaveName_0002ejspSaveName_jsp_1.java:71: Method setAttribute(java.lan
g.String, java.lang.String) not found in interface javax.servlet.http.HttpSessio
n.
session.setAttribute( "theName", name );
^
1 error
at com.sun.jsp.compiler.Main.compile(Compiled Code)
at com.sun.jsp.runtime.JspLoader.loadJSP(JspLoader.java:135)
at com.sun.jsp.runtime.JspServlet$JspServletWrapper.loadIfNecessary(JspS
ervlet.java:77)
at com.sun.jsp.runtime.JspServlet$JspServletWrapper.service(JspServlet.j
ava:87)
at com.sun.jsp.runtime.JspServlet.serviceJspFile(JspServlet.java:218)
at com.sun.jsp.runtime.JspServlet.service(JspServlet.java:294)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:155
)
at com.sun.web.core.Context.handleRequest(Context.java:414)
at com.sun.web.server.ConnectionHandler.run(Compiled Code)
+Pie Number of slices to send: Send
What is the version of servlet.jar in your classpath? also ensure you don't have multiple enteries in classpath.
[ January 07, 2003: Message edited by: varun Khanna ]
I am Arthur, King of the Britons. And this is a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 3821 times.
Similar Threads
Where to put bean class in Tomcat?
HANDLER THREAD PROBLEM and unhandled error
URGENT handler thread problem
a session problem
use of value object ( javabeans )
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 03:44:15.