Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

http 500 in jsp page

 
karthik ekantha
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Pie
Posts: 1801
28
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Kumaravadivel Subramani
Ranch Hand
Posts: 171
Java Linux Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65227
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic