• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Error in request.getParameter

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends

I am devwloping a simple JSP page which will convert INR to Dollar but I get following Error:

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /TestConver.jsp at line 13

10: <body>
11: <%
12: String str=request.getParameter("input");
13: int x=Integer.parseInt("str");
14: double d=(double)50/x;
15: %>
16:

Please find my both JSP and HTML page code as below:

HTML Page:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Conversion Table</title>
</head>
<form name ="test" method="post" action="TestConver.jsp">
<body>
<select name="sel">
<option> INR to Dollar </option>
<option> Meter to KiloMeter </option>
<option> INR to Dollar </option>
</select>

<Input type="text" value=" " name="input"> Enter the Data:</Input>

<Input type="submit" value="Enter" name="submit" > Enter</Input>


</body>
</html>

JSP Page:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import=" java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Conversion here</title>
</head>
<body>
<%
String str=request.getParameter("input");
int x=Integer.parseInt("str");
double d=(double)50/x;
%>

<%=request.getParameter("sel")%>


<%=d %>
</body>
</html>

Guide me what to do
 
Ranch Hand
Posts: 205
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is in below line



You are passing "str" and asking to convert into integer. You should pass the value of str as below and make sure the value you give to "str" is numerical value.



Also make sure that you post all your code within the code tags. This would help readers to understand your code easily.
 
Gaurav x Jain
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After chagne in code I am getting same error.
 
Gaurav x Jain
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it's working now thank you
 
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic