File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes http 500 in jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "http 500 in jsp page" Watch "http 500 in jsp page" New topic
Author

http 500 in jsp page

karthik ekantha
Ranch Hand

Joined: Feb 08, 2012
Posts: 78
when i am hitting URL ....http://localhost:8080/person/jsp/person.jsp..i got some


HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

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

exception

org.apache.jasper.JasperException: java.lang.NullPointerException
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause

java.lang.NullPointerException
org.apache.jsp.jsp.person_jsp._jspService(person_jsp.java:83)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.

in jsp file these [/size]


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page language="java" import="java.util.*" %>
<%@ page language="java" import="java.sql.*"%>
<!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>Personnel Details</title>
</head>
<body>
<center>
<%!

String name="";
String fname="";
String mno="";
String comp="";
String add="";
String City="";
String States="";
%>
<%

HashMap personalDetailsMap2 = (HashMap)session.getAttribute("paramlist");

if(personalDetailsMap2.get("name")!=null && personalDetailsMap2.get("name")!="")
{
name = personalDetailsMap2.get("name").toString();
fname=personalDetailsMap2.get("fname").toString();
mno=personalDetailsMap2.get("mno").toString();
comp=personalDetailsMap2.get("comp").toString();
add=personalDetailsMap2.get("add").toString();
City=personalDetailsMap2.get("City").toString();
States=personalDetailsMap2.get("States").toString();
}
%>

<%if(session.getAttribute("paramlist").equals(null)) {%>


<form action="/person/Person" method="post">

<tr><td colspan=2 style="font-weight:bold;" align="center"> User Information<br></td></tr>
<tr><td colspan=2 align="center" height="10px"></td></tr>
<tr><td>NAME </td><td><input type="text" name="name" value="name"><br></td></tr>
<tr><td>FatherName </td><td><input type="text" name="fname" value="fname"><br></td></tr>
<tr><td>MobileNO </td><td><input type="text" name="mno" value="mno"><br></td></tr>
<tr><td> Company </td><td><input type="text" name="comp" value="comp"><br></td></tr>
<tr><td>Address </td><td> <textarea type="text" name="add" value="add"></textarea><br></td></tr>

City:
<select name="City">
<option value="Bangalore">Bangalore</option>
<option value="Chennai">Chennai</option>
<option value="Hyderbad">Hyderbad</option>
<option value="Mumbai">Mumbai</option>
</select>
<br>

States:
<select name="States">
<option value="Kanataka">Kanataka</option>
<option value="Tamilnadu">Tamilnadu</option>
<option value="Andrapradesh">Andrapradesh</option>
<option value="Maharastra">Maharastra</option>
</select><br>

<input type="submit" name="b1" value="Save" >
<input type="submit" name="b1" value="Edit"> <br>

</form>

<% } else {%>
<form action="/person/Person" method="post">

<tr><td colspan=2 style="font-weight:bold;" align="center"> User Information<br></td></tr>
<tr><td colspan=2 align="center" height="10px"></td></tr>
<tr><td> NAME </td><td><input type="text" name="name" value=<%= name%>><br></td></tr>
<tr><td>FatherName </td><td><input type="text" name="fname" value=<%= fname%>><br></td></tr>
<tr><td>MobileNO </td><td><input type="text" name="mno" value=<%= mno%>><br></td></tr>
<tr><td> Company </td><td><input type="text" name="comp" value=<%= comp%>><br></td></tr>
<tr><td>ADDRESS </td><td> <textarea type="text" name="add" value=<%= add%>></textarea><br></td></tr>

City:

<% if( City.equals("Bangalore")) {%>
<select name="City">
<option value="Bangalore" selected = "selected">Bangalore</option>
<option value="Chennai">Chennai</option>
<option value="Hyderbad">Hyderbad</option>
<option value="Mumbai">Mumbai</option>
</select>
<% } %>
<% if( City.equals("Chennai")) {%>
<select name="City">
<option value="Bangalore" >Bangalore</option>
<option value="Chennai" selected = "selected">Chennai</option>
<option value="Hyderbad">Hyderbad</option>
<option value="Mumbai">Mumbai</option>
</select>
<% } %>
<% if( City.equals("Hyderbad")) {%>
<select name="City">
<option value="Bangalore" >Bangalore</option>
<option value="Chennai" >Chennai</option>
<option value="Hyderbad"selected = "selected">Hyderbad</option>
<option value="Mumbai">Mumbai</option>
</select>
<% } %>
<% if( City.equals("Mumbai")) {%>
<select name="City">
<option value="Bangalore" >Bangalore</option>
<option value="Chennai" >Chennai</option>
<option value="Hyderbad">Hyderbad</option>
<option value="Mumbai"selected = "selected">Mumbai</option>
</select>
<% } %>
<br>

States:
<% if( States.equals("Kanataka")) {%>
<select name="States">
<option value="Kanataka"selected = "selected">Kanataka</option>
<option value="Tamilnadu">Tamilnadu</option>
<option value="Andrapradesh">Andrapradesh</option>
<option value="Maharastra">Maharastra</option>
</select>
<% } %>
<% if( States.equals("Tamilnadu")) {%>
<select name="States">
<option value="Kanataka">Kanataka</option>
<option value="Tamilnadu"selected = "selected">Tamilnadu</option>
<option value="Andrapradesh">Andrapradesh</option>
<option value="Maharastra">Maharastra</option>
</select>
<% } %>
<% if( States.equals("Andrapradesh")) {%>
<select name="States">
<option value="Kanataka">Kanataka</option>
<option value="Tamilnadu">Tamilnadu</option>
<option value="Andrapradesh"selected = "selected">Andrapradesh</option>
<option value="Maharastra">Maharastra</option>
</select>
<% } %>
<% if( States.equals("Maharastra")) {%>
<select name="States">
<option value="Kanataka">Kanataka</option>
<option value="Tamilnadu">Tamilnadu</option>
<option value="Andrapradesh">Andrapradesh</option>
<option value="Maharastra"selected = "selected">Maharastra</option>
</select>
<% } %>


<br>

<input type="submit" name="b1" value="Save" >
<input type="submit" name="b1" value="Edit"> <br>

</form>
<%}%>

</center>
</body>
</html>


J. Kevin Robbins
Ranch Hand

Joined: Dec 16, 2010
Posts: 632
    
    7

First, please use code tags when posting code to make it readable. Second, you need to learn to use JSTL and EL and stop using scriptlets. Third, unrelated to your error, you have table rows that are not inside a table. Finally, you are trying to pull an attribute called paramlist from the session and it doesn't exist, hence the null pointer error.

There are other syntax errors that you should be able to spot with a decent editor such as Notepad++, if you aren't using an IDE.


"There is no reason for any individual to have a computer in his home" ~ Ken Olson, Co-founder of DEC, 1977
Kumaravadivel Subramani
Ranch Hand

Joined: Jul 05, 2008
Posts: 166

What would happen if the personalDetailsMap2 is null?


I guess this would be the problem, try to print the same before proceeding to extract an item from it.


No pain, No gain.
OCJP 1.6
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60063
    
  65

Jk Robbins is quite correct. Use of scriptlets and Java code in a JSP is a bad practice that has been discredited for 10 years now. Time to update your knowledge to use the JSTL and EL in modern JSP pages.

These make it almost impossible to introduce error such a null pointer exceptions into a JSP.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: http 500 in jsp page
 
Similar Threads
Retaining selected values in a portlet
http error?
how to assign variable in text area?
<jsp:setProperty> sets null values in the bean
Redirct page in Tilse with JSTL