• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I got http-500 error in servlet and jsp.how to find error?

 
karthik ekantha
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
person.doGet(person.java:42)
person.doPost(person.java:49)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause

java.lang.NullPointerException
org.apache.jsp.jsp.output_jsp._jspService(output_jsp.java:73)
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)
person.doGet(person.java:42)
person.doPost(person.java:49)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
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.

 
karthik ekantha
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is my servlet program.....this is contain person details get from 1st jsp file and display to another jsp file



import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


public class person extends HttpServlet {

public void doGet (HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
{
int i=0;
String paramName = null;


HttpSession session=request.getSession();
Enumeration<String> param = request.getParameterNames();

while(param.hasMoreElements())
{
paramName = param.nextElement();
String[] paramValues = request.getParameterValues(paramName);



}
session.setAttribute("paramlist",paramName );



RequestDispatcher dispatch=request.getRequestDispatcher("/jsp/output.jsp");
if ( null != dispatch ) {
dispatch.forward(request,response);
}


}
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
 
karthik ekantha
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this type of error ll come .how to idetify and solve this error .please help me any one
 
karthik ekantha
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is ouput .jsp





<%@page import="java.util.List"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.Map"%>
<%@ 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>Output.jsp</title>
</head>
<body>

this is another output.jsp page
<%
List paramlist=(List)request.getAttribute("paramlist");

Iterator itr =paramlist.iterator();
for (itr=paramlist.iterator(); itr.hasNext(); )
{
%>
<tr>
<td ><%=itr.next()%></td>
<td ><%=itr.next()%></td>
</tr>
<%}%>

</body>
</html>
 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use the code tag to add your code to post.
 
Kumaravadivel Subramani
Ranch Hand
Posts: 171
Java Linux Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you add print statements before this line, I suspect the list reference paramlist would be null. Also have a check for null and if not then go with iteration on it.

 
karthik ekantha
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i can change add the print statement...now following error came now ..

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: An exception occurred processing JSP page /jsp/output.jsp at line 19

16: out.println(request.getAttribute("paramlist"));
17: List paramlist=(List)request.getAttribute("paramlist");
18:
19: Iterator itr =paramlist.iterator();
20: for (itr=paramlist.iterator(); itr.hasNext(); )
21: {
22: %>


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
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)
person.doGet(person.java:42)
person.doPost(person.java:49)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause

java.lang.NullPointerException
org.apache.jsp.jsp.output_jsp._jspService(output_jsp.java:74)
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)
person.doGet(person.java:42)
person.doPost(person.java:49)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
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.


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

Apache Tomcat/6.0.18

 
karthik ekantha
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for your response.need possible this solve this problem
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic