?
Solved

convert String to int in JavaServer Pages

Posted on 2003-03-05
5
Medium Priority
?
528 Views
Last Modified: 2008-02-26
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
Comment
Question by:r_muthu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 1

Expert Comment

by:urxlnc
ID: 8078620
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
 
LVL 1

Accepted Solution

by:
urxlnc earned 80 total points
ID: 8078623
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

Major Serverless Shift

Comparison of major players like AWS, Microsoft Azure, IBM Bluemix, and Google Cloud Platform

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question