• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Difficulty in compiling JSP

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Appears to be duplicate of this thread. Closing
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, it's not a duplicate, sorry.

The thread was moved to JSP and moved back.

Opening it again.
reply
    Bookmark Topic Watch Topic
  • New Topic