• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP Should recognise fundamental class Enumeration?

 
northfield Sid
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working with JSP forms.
I have got this error on class Enumeration not found. I do not why I am getting this error since it is a fundamental class and JSP should recognise this?
<HTML><HEAD><TITLE>Dynamic Form</TITLE></HEAD>
<BODY>
<B>Form</B>
<FORM ACTION=dynamicForm.jsp METHOD=POST>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>
<% String[] textFields = {"FirstName", "LastName", "Address", "City", "Zip"};
for(int j=0; j<textFields.length; j++){ %>
<TR> <TD> <%=textFields[j]%>: </TD>
<TD> <INPUT TYPE=TEXT NAME=<%=textFields[j]%>> </TD>
</TR>
<% } %>
<TR> <TD> State </TD>
<TD> <SELECT NAME=State>
<% String[] states = {"AZ", "CA", "NM", "MA", "ME", "MD", "..."};
for(int s=0; s<states.length; s++) { %>
<OPTION><%=states[s]%></OPTION>
<% } %>
</SELECT></TD>
</TR>
<TR> <TD> Card Number </TD>
<TD> <INPUT TYPE=TEXT NAME=cNumber></TD>
</TR>
<TR> <TD> Card Type </TD>
<TD> <SELECT NAME=CardType>
<% String[] cTypes = {"Amex", "Visa", "Master Card", "Discovery", "..."};
for(int t=0; t<cTypes.length; t++) { %>
<OPTION><%=cTypes[t]%></OPTION>
<% } %>
</SELECT></TD>
</TR>
<TR> <TD> Expiration Date (MM/DD/YYYY) </TD>
<TD> <INPUT TYPE=TEXT NAME=cMonth SIZE=2><INPUT TYPE=TEXT NAME=cDay SIZE=2>
<SELECT NAME=cYear>
<% int startYear = 2000;
int endYear = 2010;
for(int y=startYear; y<endYear; y++) { %>
<OPTION><%=y%></OPTION>
<% } %>
</SELECT></TD>
</TR>
</TABLE>
<INPUT TYPE=SUBMIT VALUE=Submit>
</FORM>
<HR>
<B>Form Content</B><BR>
<TABLE>
<% Enumeration parameters = request.getParameterNames();
while(parameters.hasMoreElements()){
String parameterName = (String)parameters.nextElement();
String parameterValue = request.getParameter(parameterName); %>
<TR>
<TD><%=parameterName%></TD>
<TD><%=parameterValue%></TD>
</TR>
<% } %>
</BODY></HTML>

Location: /myJSPs/jsp/Hour11/dynamicForm.jsp
Internal Servlet Error:
org.apache.jasper.JasperException: Unable to compile D:\tomcat\jakarta-tomcat-3.3.1\work\DEFAULT\myJSPs\jsp\Hour11\dynamicForm_1.java:150: Class jsp.Hour11.Enumeration not found.
Enumeration parameters = request.getParameterNames();
^
1 error
at org.apache.tomcat.facade.JasperLiaison.javac(JspInterceptor.java:898)
at org.apache.tomcat.facade.JasperLiaison.processJspFile(JspInterceptor.java:733)
at org.apache.tomcat.facade.JspInterceptor.requestMap(JspInterceptor.java:506)
at org.apache.tomcat.core.ContextManager.processRequest(ContextManager.java:968)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:875)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:484)
Please help???
 
chanoch wiggers
Author
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its not a fundamental class though, it belongs to java.util. So you will need to import java.util at the top of the jsp page.
chanoch
 
northfield Sid
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx your suggestion works.
In Java programming I think you don't need to import this package?? I think the util and maths package is imported implicitly. ANy way the program works with the import statement.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang is imported implicitly. java.util you must explicitly import
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic