aspose file tools*
The moose likes JSP and the fly likes I am not getting forwarded to another page where i want to go Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "I am not getting forwarded to another page where i want to go" Watch "I am not getting forwarded to another page where i want to go" New topic
Author

I am not getting forwarded to another page where i want to go

Rushi Patel
Greenhorn

Joined: Sep 14, 2011
Posts: 17
hello all,
I am preparing an Online TestModule...
in which i am dealing with

CreateTest.jsp
CreateTestServlet.java (controller)
CreateTestModel.java (model)

Destination Page::
----------------------
CreateTestForm.jsp

Error I am getting is::
--------------------------

Oct 02, 2011 11:57:24 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet CreateTestServlet threw exception
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

at org.apache.jsp.CreateTestForm_jsp._jspService(CreateTestForm_jsp.java:58)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at controller.CreateTestServlet.processRequest(CreateTestServlet.java:58)
at controller.CreateTestServlet.doPost(CreateTestServlet.java:89)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
at java.lang.Thread.run(Thread.java:722)


all files code are as follows:
==================

CreateTest.jsp
-----------------------------


CreateTestServlet.java
------------------------------------


CreateTestModel.java
----------------------------------
Gopakumar Naryanan
Ranch Hand

Joined: Jan 15, 2011
Posts: 72

Rushi Patel wrote:hello all,
Oct 02, 2011 11:57:24 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet CreateTestServlet threw exception
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

at org.apache.jsp.CreateTestForm_jsp._jspService(CreateTestForm_jsp.java:58)
[/color]


This means in your CreateTestForm.jsp , you are trying to cast an Integer to String.

Please provide the code for your CreateTestForm.jsp


Thanks & Regards
Gopakumar
Rushi Patel
Greenhorn

Joined: Sep 14, 2011
Posts: 17
gopakumar kiing wrote:


it had problm in some of jsp scriplets....
now i have used Static variable of "qno"
instead of using context parameter...!

now its completely working...!
Rushi Patel
Greenhorn

Joined: Sep 14, 2011
Posts: 17


Information in Red was not supported , so i have put it into comment and now its working for me but i am trying to get reason for that why it didnot supported...!
Gopakumar Naryanan
Ranch Hand

Joined: Jan 15, 2011
Posts: 72

Hi ,

There is no possibility that the highlighted code causing the specified Exception.
You might have changed the code.
In the Exception Message it showed that you were trying to cast an Integer type to String.
(this is nowhere found in your highlighted code)

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

You shouldn't have any Java code in your JSP to begin with. That is a poor practice that has been discredited for 10 years now!

In any case, use red is a poor way topmost code. Red on tan is barely readable.

Rather, please be sure to use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information. Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rushi Patel
Greenhorn

Joined: Sep 14, 2011
Posts: 17
gopakumar kiing wrote:Hi ,

In this jsp code,....
when i remove this commented part ...its absolutely work very well...
but its not working with that portion uncommented.,...!

you got my point ??



Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

From looking at the trace, it seems as if the exception is occurring in a file that has not even bee shown to us.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18662
    
    8

On the other hand, the posted code clearly shows a cast to the String type. If you were to guess that the exception referred to that line of code, then that would mean that the expression being cast was actually of the Integer type.

And then somebody familiar with the application in question should be able to determine what is setting that servlet context attribute and fix the problem accordingly.
Gopakumar Naryanan
Ranch Hand

Joined: Jan 15, 2011
Posts: 72

Hi Rushi,

Still my reply remains the same.
You might have changed the code.. Nowhere you are trying to convert an Integer to String.
Ravi Khadgi
Greenhorn

Joined: Aug 06, 2010
Posts: 20

getServletContext().getAttribute("tnum") should be of type "Integer".
(String)getServletContext().getAttribute("tnum") tries to convert an "Integer" to "String" type.

I recommend you to use toString() method if you want the String.
Use Integer.intValue() function if you want the primitive int.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

Ravi Khadgi wrote:I recommend you to use toString() method if you want the String.

That could cause a null pointer exception if the scoped variable does not exist. Best to use String.valueOf() if there is a need for String conversion (which I am not convinced of) .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I am not getting forwarded to another page where i want to go