Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to convert String to int in JSP?

843836Jul 18 2004 — edited Sep 7 2007
Hi,

I set a session attribute in Servlet and want use it in JSP, How can I convert it to int or Integer?
the line in my code doesn't work:
int quantity=(int)session.getAttribute("vehiclequantity") ;

Thanks in advance.
Wolf
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<HTML>
<HEAD>
<TITLE>Using the for Statement</TITLE>
</HEAD>

<BODY>
<H1>Using the for Statement</H1>
<%=session.getAttribute("vehiclequantity") %>;

<%
int loopIndex;
int quantity=(int)session.getAttribute("vehiclequantity") ;

out.println(quantity);

for (loopIndex = 1; loopIndex <=2; loopIndex++) {
out.println("This is iteration number "
+ loopIndex + "<BR>");
}
%>
</BODY>
</HTML>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 5 2007
Added on Jul 18 2004
14 comments
2,081 views