ERROR WITH SERVLET CALLING
WHEN I AM CALLING A SERVLET, I AM GETTING THIS ERROR
COULD ANYONE TELL ME WHAT DOES THIS MEAN????
SATISH
500 Internal Server Error
The servlet named cart at the requested URL
http://localhost:8080/servlet/cart
reported this exception: java.lang.ClassCastException. Please report this
to the administrator of the web server.
java.lang.ClassCastException at cart.doPost(Compiled Code) at javax.servlet.http.HttpServlet.service(Compiled
Code) at javax.servlet.http.HttpServlet.service(Compiled Code) at com.sun.server.ServletState.callService(Compiled
Code) at com.sun.server.ServletManager.callServletService(Compiled Code)
at com.sun.server.http.servlet.InvokerServlet.service(Compiled Code) at javax.servlet.http.HttpServlet.service(Compiled
Code) at com.sun.server.ServletState.callService(Compiled Code) at com.sun.server.ServletManager.callServletService(Compiled
Code) at com.sun.server.ProcessingState.invokeTargetServlet(Compiled Code)
at com.sun.server.http.HttpProcessingState.execute(Compiled Code) at com.sun.server.http.stages.Runner.process(Compiled
Code) at com.sun.server.ProcessingSupport.process(Compiled Code) at com.sun.server.Service.process(Compiled
Code) at com.sun.server.http.HttpServiceHandler.handleRequest(Compiled Code)
at com.sun.server.http.HttpServiceHandler.handleRequest(Compiled Code) at
com.sun.server.HandlerThread.run(Compiled Code)
Re: ERROR WITH SERVLET CALLING
it means that you are trying to cast something which is not allowed, best
way to deal with it is check all the places where you are casting in ur cart
servlet and make sure that you r casting it properly or you can paste your
code here so that I can take a look at it. Another way is if you are using
VIsual Age for Java, then set a break point and run step by step through
the code.
hope this helps..
Badri.
"SATISH" <SATISH141@ENGLAND.COM> wrote:
>
>WHEN I AM CALLING A SERVLET, I AM GETTING THIS ERROR
>
>COULD ANYONE TELL ME WHAT DOES THIS MEAN????
>
>SATISH
>
>
>500 Internal Server Error
>The servlet named cart at the requested URL
>
>http://localhost:8080/servlet/cart
>reported this exception: java.lang.ClassCastException. Please report this
>to the administrator of the web server.
>
>java.lang.ClassCastException at cart.doPost(Compiled Code) at javax.servlet.http.HttpServlet.service(Compiled
>Code) at javax.servlet.http.HttpServlet.service(Compiled Code) at com.sun.server.ServletState.callService(Compiled
>Code) at com.sun.server.ServletManager.callServletService(Compiled Code)
>at com.sun.server.http.servlet.InvokerServlet.service(Compiled Code) at
javax.servlet.http.HttpServlet.service(Compiled
>Code) at com.sun.server.ServletState.callService(Compiled Code) at com.sun.server.ServletManager.callServletService(Compiled
>Code) at com.sun.server.ProcessingState.invokeTargetServlet(Compiled Code)
>at com.sun.server.http.HttpProcessingState.execute(Compiled Code) at com.sun.server.http.stages.Runner.process(Compiled
>Code) at com.sun.server.ProcessingSupport.process(Compiled Code) at com.sun.server.Service.process(Compiled
>Code) at com.sun.server.http.HttpServiceHandler.handleRequest(Compiled Code)
>at com.sun.server.http.HttpServiceHandler.handleRequest(Compiled Code) at
>com.sun.server.HandlerThread.run(Compiled Code)
Re: ERROR WITH SERVLET CALLING
Dear Badri,
Thanks for your response, but pls look and the code and let me know, as
to where I am casting wrong?
Satish
public class cart extends HttpServlet
{
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
HttpSession session = req.getSession(true);
String[ ] items = ( String [ ] ) session.getValue("cart.items");
out.println("<body bgcolor=333699>");
out.println("<html> ");
out.println("<H3>you currently have the following
items in your cart:</H3><br>");
if(items!=null)
{
out.println("<UL>");
for (int i = 0 ; i < items.length ; i++ )
{
out.println("<LI>" + items[i] );
}
out.println("</UL>");
}
out.println("</body>");
out.println("</html> ");
}
}
Re: ERROR WITH SERVLET CALLING
I think the "cart.items" you are getting from the session may not be a String
array, that is the only possible error in the code. you can check the code
where you are populating the session with "cart.items".
Good Luck
--Badri.
"satish" <satish141@england.com> wrote:
>
>
>
>Dear Badri,
>
> Thanks for your response, but pls look and the code and let me know, as
>to where I am casting wrong?
>
>
>Satish
>
>
>
>
>
>
> public class cart extends HttpServlet
> {
>
>
>
>
>
> public void doPost(HttpServletRequest req, HttpServletResponse res)
>throws ServletException, IOException
> {
>
>
>
>
> res.setContentType("text/html");
> PrintWriter out = res.getWriter();
>
>
> HttpSession session = req.getSession(true);
>
> String[ ] items = ( String [ ] ) session.getValue("cart.items");
>
>
>
> out.println("<body bgcolor=333699>");
>
>
> out.println("<html> ");
>
>
>
> out.println("<H3>you currently have the following
>items in your cart:</H3><br>");
>
> if(items!=null)
> {
>
> out.println("<UL>");
>
>
> for (int i = 0 ; i < items.length ; i++ )
> {
>
> out.println("<LI>" + items[i] );
>
> }
>
> out.println("</UL>");
> }
>
>
>
>
>
> out.println("</body>");
>
>
> out.println("</html> ");
>
>
>
>
>
>
> }
>
>
>
> }
>
>
>
>