This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes Error in request.getParameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Error in request.getParameter" Watch "Error in request.getParameter" New topic
Author

Error in request.getParameter

Gaurav x Jain
Ranch Hand

Joined: Feb 01, 2011
Posts: 39
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
Eshwar Prasad
Ranch Hand

Joined: Mar 21, 2008
Posts: 202
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

Joined: Feb 01, 2011
Posts: 39
After chagne in code I am getting same error.
Gaurav x Jain
Ranch Hand

Joined: Feb 01, 2011
Posts: 39
it's working now thank you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error in request.getParameter
 
Similar Threads
NULL
Request Attribute confusion
getParameter() method gives null
Error: SQL Exception
Cannot fetch data from arraylist