| Author |
Difficulty in compiling JSP
|
renu richard
Ranch Hand
Joined: Oct 06, 2008
Posts: 116
|
|
Hi, I have some problem in compiling JSP. Basically what i am trying to do is that 1)a servlet is setting an attribute [attribute name:choice] and then calling a JSP. Which is using that attribute [attribute name:choice]. I am getting an error as shown below. [code] 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: An exception occurred processing JSP page /welcome.jsp at line 24 21: out.println( date ); 22: out.println( "<BR>Your machine's address is " ); 23: out.println( request.getRemoteHost()); 24: ArrayList al =(ArrayList)request.getAttribute("choice"); 25: Iterator it = al.iterator(); 26: while (it.hasNext()){ 27: %> Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) com.example.Sample.doPost(Sample.java:17) javax.servlet.http.HttpServlet.service(HttpServlet.java:637) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) root cause java.lang.ClassCastException: [Ljava.lang.String; org.apache.jsp.welcome_jsp._jspService(welcome_jsp.java:79) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) com.example.Sample.doPost(Sample.java:17) javax.servlet.http.HttpServlet.service(HttpServlet.java:637) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs. --------------------------------------------------------------------------- Apache Tomcat/6.0.18 ---------------------------------------------------------------------------- IN the servelt (code snippet) : String[] multiplechoice = request.getParameterValues("toon"); request.setAttribute("choice",multiplechoice); RequestDispatcher view = request.getRequestDispatcher("welcome.jsp"); --------------------------------------------------------------------------- Can someone please help me
|
Cheers,
Richard
|
 |
Amit Ghorpade
Bartender
Joined: Jun 06, 2007
Posts: 2552
|
|
|
As you can see from the stack trace and the code, you are setting an attribute of type String [] and then trying to cast it into an ArrayList, which won't do.
|
SCJP, SCWCD.
|Asking Good Questions|
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
|
|
|
Appears to be duplicate of this thread. Closing
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
|
|
Oh, it's not a duplicate, sorry. The thread was moved to JSP and moved back. Opening it again.
|
 |
 |
|
|
subject: Difficulty in compiling JSP
|
|
|