HI folks,
I got some exception while exceuting servlet and jsp code (along with javabean class)..Here is that exception..
please tell me the meaning of that exception as well as the solution for it..
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: Unable to compile class for JSP:
An error occurred at line: 22 in the generated java file
The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory
An error occurred at line: 5 in the jsp file: /UseBeanDemo.jsp
Person cannot be resolved to a type
2: <html>
3: <body>
4: <%
5: Person p = (Person) request.getAttribute("name");
6:
7: %>
8:
An error occurred at line: 5 in the jsp file: /UseBeanDemo.jsp
Person cannot be resolved to a type
2: <html>
3: <body>
4: <%
5: Person p = (Person) request.getAttribute("name");
6:
7: %>
8:
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
UseBeanDemo.doGet(UseBeanDemo.java:25)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.
Here is the code for it..
//This is Java bean class callled "Person"
public class Person {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
//and this is the servlet code
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class UseBeanDemo extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
Person p = new Person();
p.setName("Harishwar");
request.setAttribute("name", p);
RequestDispatcher dispatcher = request.getRequestDispatcher("UseBeanDemo.jsp");
dispatcher.forward(request, response);
}
}
//and this is the small jsp code
<html>
<body>
<%
Person p = (Person) request.getAttribute("name");
%>
<%=
p.getName()
%>
</body>
</html>