• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 535
  • Last Modified:

convert String to int in JavaServer Pages

How can I convert String to int in JavaServer PagesTM?

I'm having a problem converting String to int on JavaServer Pages. This is the code I used:

 

 <%
String ss= request.getParameter("prior");  
int ii = Integer.parseInt(ss);
%>
ii=<%=ii%>

The output i got is
 
 A Servlet Exception Has Occurred
java.lang.NumberFormatException: 15
at java.lang.Integer.parseInt(Integer.java:414)
     at java.lang.Integer.parseInt(Integer.java:454)


the value for prior=15




Thanks,
Muthu



0
r_muthu
Asked:
r_muthu
  • 2
1 Solution
 
urxlncCommented:
I assume you have imported the necessary files.
<%@ page import="java.jang.*, java.io.*" %>

<%
String ss= request.getParameter("prior");  
int ii = Integer.parseInt(ss);
%>
ii=<%= ii %>

The space is important in <%= ii %>.
Try now!!!
0
 
urxlncCommented:
Sorry for the previous typo.

I assume you have imported the necessary files.
<%@ page import="java.lang.*, java.io.*" %>

<%
String ss= request.getParameter("prior");  
int ii = Integer.parseInt(ss);
%>
ii=<%= ii %>

The space is important in <%= ii %>.
Try now!!!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now