HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.ClassCastException: java.lang.Integer
InfonetFilter.doFilter(InfonetFilter.java:29)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.
Apache Tomcat/6.0.18
Piyush Mangal wrote:
Do you really have to restart your machine? I think you meant restarting your tomcat server. The issue is ClassCastException.to run my program again i have to restart my computer.
Yes it can be done, we just have to figure out how.
Anurag Verma wrote:the problem is in InfonetFilter.java line number 29, where you are casting into Integer.
Megha Singhal wrote:
Anurag Verma wrote:the problem is in InfonetFilter.java line number 29, where you are casting into Integer.
is there is any problem in the session in my first servlet i am setting session like following
and in my second servlet i am getting session like following
sanket singh wrote:Paste line 29 of InfonetFilter.java
and
try to change your second servlet to
int ccno=Integer.parstInt(session.getAttribute("ccno"));
i think it might work.
Ben.java:25: cannot find symbol
symbol : method parstInt(java.lang.Object)
location: class java.lang.Integer
int ccno=Integer.parstInt(session.getAttribute("ccno"));
^
1 error
Bear Bibeault wrote:Do you really need us to check your spelling?
Eshwin Sukhdeve wrote:just try with session.putValue() method and get the session value using session.getValue()
Megha Singhal wrote:
Bear Bibeault wrote:Do you really need us to check your spelling?
sorry i didn't observe that.
i correct it but it is still giving error.
actualy waht i observe is that http session is not working on my server, when i trying to redirect to any jsp or any other servlet page it is still giving the same error and when i diasabled those line where i made httpsession in first servlet its redirecting to any of the page.
so is there is any alternative of http session to make session for the integer variable.
avneesh atri wrote:
Megha Singhal wrote:
Bear Bibeault wrote:Do you really need us to check your spelling?
sorry i didn't observe that.
i correct it but it is still giving error.
actualy waht i observe is that http session is not working on my server, when i trying to redirect to any jsp or any other servlet page it is still giving the same error and when i diasabled those line where i made httpsession in first servlet its redirecting to any of the page.
so is there is any alternative of http session to make session for the integer variable.
if you are using this line of code
"int ccno=Integer.parseInt(session.getAttribute("ccno")); "
then it will through an exception at runtime because in method parseInt ,argument has to be a string not a int or Integer or anything else.
So make sure when you are setting an attribute in the session it must be of type Integer and when you are using getAttribute() method, type cast it to Integer , as the return type of this method is Object.
If you do this it will surely work.
Ben.java:28: incompatible types
found : java.lang.Object
required: int
int ccno=session.getAttribute("ccno");
^
1 error
Tim Moores wrote:Read the javadocs of HttpSession to find out what data type HttpSession.getAttribute returns. You seem to have removed a critical piece that was present in your earlier code.
Ben.java:28: incompatible types
found : java.lang.Object
required: int
int ccno =session.getAttribute("ccno");
^
1 error
Megha Singhal wrote:
avneesh atri wrote:
Megha Singhal wrote:
Bear Bibeault wrote:Do you really need us to check your spelling?
sorry i didn't observe that.
i correct it but it is still giving error.
actualy waht i observe is that http session is not working on my server, when i trying to redirect to any jsp or any other servlet page it is still giving the same error and when i diasabled those line where i made httpsession in first servlet its redirecting to any of the page.
so is there is any alternative of http session to make session for the integer variable.
if you are using this line of code
"int ccno=Integer.parseInt(session.getAttribute("ccno")); "
then it will through an exception at runtime because in method parseInt ,argument has to be a string not a int or Integer or anything else.
So make sure when you are setting an attribute in the session it must be of type Integer and when you are using getAttribute() method, type cast it to Integer , as the return type of this method is Object.
If you do this it will surely work.
if i am doing that as per you are saying it is giving following error
Ben.java:28: incompatible types
found : java.lang.Object
required: int
int ccno=session.getAttribute("ccno");
^
1 error
Megha Singhal wrote:
Tim Moores wrote:Read the javadocs of HttpSession to find out what data type HttpSession.getAttribute returns. You seem to have removed a critical piece that was present in your earlier code.
it is saying "Returns the object bound with the specified name in this session" so in my code it should return int value
Swastik Dey wrote:
Megha Singhal wrote:
Swastik Dey wrote:
still same problem
not working
Swastik
Matthew Brown wrote:
Megha Singhal wrote:
Swastik Dey wrote:
still same problem
not working
That's not a cast. Although it would still probably work if the attribute was an Integer value.
The important thing is to work out exactly what session.getAttribute("ccno") is returning. Get your code to print out or log the value and the type, and that
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.ClassCastException: java.lang.Integer
InfonetFilter.doFilter(InfonetFilter.java:29)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.
--------------------------------------------------------------------------------
Apache Tomcat/6.0.18
Swastik
Swastik Dey wrote:From the log stack trace it seems that you don't have exception in any of the above two codes.
java.lang.ClassCastException: java.lang.Integer
InfonetFilter.doFilter(InfonetFilter.java:29)
rather in a file InfonetFilter.java. What code do you have in that file in line number 29?
Swastik
OCPJP
In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower