Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Passing form data from html page to JSP page

800306Feb 23 2007 — edited Feb 26 2007
Hi,

I have a simple HTML page with a form on it that sends the information to a JSP page that stores the form data in a JSP session. I created a simple form that asks for the user's name, sends it to the JSP page, stores that in a session, then sends it to another JSP page which displays the name. This worked fine.

However, I added another input box to my form that asks for the user's age to do the same steps as outlined above. This does not work, and I'm not sure why. Here's the code from my HTML page:
<form method=post action="savename.jsp">
What's your name? 
<input type=text name=username size=20 />
<p />
What's your age?
<input type=text name=age size=20 />
<p />
<input type=submit />
Here's the code from my JSP page, savename.jsp (later on in the JSP page it links to another page, but that is not relevant):
<%
String name = request.getParameter("username");
String age = request.getParamater("age");
session.setAttribute("theName", name);
session.setAttribute("theAge", age);
%>
Finally, here is the error message from Tomcat 6.0.9:
HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 3 in the jsp file: /savename.jsp
The method getParamater(String) is undefined for the type HttpServletRequest
1: <%
2: String name = request.getParameter("username");
3: String age = request.getParamater("age");
4: session.setAttribute("theName", name);
5: session.setAttribute("theAge", age);
6: %>


Stacktrace:
	org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
	org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
	org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
I do not understand the error, as it works fine when I simply try to retrieve "theName", but breaks when I try to retrieve both.

What is it I am missing here?

Thanks,
Dan
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 26 2007
Added on Feb 23 2007
2 comments
810 views