I am just doing a project on Job Portal where an Employer Posts a Job and Job Seeker Applies for a Job .
Here is the part of the coding where an Employer tries to post a Job (Postjob.jsp)
Postjob.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>Welcome employer</title>
</head>
<body>
<div style="background-color:#003333"> <font color="green"> <b> <h1><pre> Freshers World </pre></h1>
<p><i><pre> <font size="5"> freshers way to
moving ahead</font>>></pre></i></p></b></font></div>
<body>
<h3><font color="green"><i>welcome <%=session.getAttribute("username") %> to Fresher's World</i></font></h3>
<form action="PJProcess" method="POST">
<table>
<tr><td>Job Id <input type="text" name="Jobid" value=""/></td></tr>
<tr><td>Designation<input type="text" name="Designation" value=""/></td></tr>
<tr><td><p align=justify>skills(use control for multiple select)*</p><select name="Skills" multiple="multiple">
<option selected value="noskill"> - skills - </option>
<option value="Adobe photoshop">Adobe photoshop</option>
<option value="c">c</option>
<option value="c++">c++</option>
<option value="DBMS">DBMS</option>
<option value="DotNet">DotNet</option>
<option value="html">html</option>
<option value="java">
java</option>
<option value="J2EE">
J2EE</option>
<option value="mySQL">mySQL</option>
<option value="oracle">oracle</option>
<option value="PL/SQL">PL/SQL</option>
<option value="UML">UML</option>
<option value="Visual basic">Visual basic</option>
</select>
</td></tr>
<tr><td>Location<input type="text" name="Location" value=""/>
<tr><td>Eligibility Criteria <input type="text" name="Eligibility" maxlength="100" value=""/>
<tr><td><input type="submit" value="PostJob" name="PostJob" width="50"/></td></tr>
</table>
</form>
</body>
</html>
Here is the Code of the
Servlet to validate the Form in the Postjob.jsp
PJProcess.java
After i click PostJob of the PostJob.jsp . The page redirects to Success page but when i Post with no Values , it doesn't get redirected to the Error page(PJerror.jsp).
Here is the coding for Error page :
PJError.jsp
<%@page import="java.util.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>
JSP Page</title>
</head>
<body>
<div style="background-color:#003333"> <font color="green"> <b> <h1><pre> Freshers World </pre></h1>
<p><i><pre> <font size="5"> freshers way to
moving ahead</font>>></pre></i></p></b></font></div>
<%
List errors=(List)request.getAttribute("errorlist");
Iterator i=errors.iterator();
while(i.hasNext())
{
out.println(i.next());
}
%>
<h1>Hello World!! Error Page</h1>
</body>
</html>
After Trying to execute the above codings i get the following Runtime Exceptions.
Exceptions
WARNING: ApplicationDispatcher[/FresshersWorld] PWC1231: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at org.apache.jsp.PJError_jsp._jspService(PJError_jsp.java:63)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:787)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:649)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:483)
at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:454)
at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:350)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:300)
at com.PJProcess.processRequest(PJProcess.java:45)
at com.PJProcess.doPost(PJProcess.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)
WARNING: StandardWrapperValve[PJProcess]: PWC1406: Servlet.service() for servlet PJProcess threw exception
java.lang.NullPointerException
at org.apache.jsp.PJError_jsp._jspService(PJError_jsp.java:63)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:787)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:649)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:483)
at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:454)
at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:350)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:300)
at com.PJProcess.processRequest(PJProcess.java:45)
at com.PJProcess.doPost(PJProcess.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)
After executing the code , i could find that Success page is getting dispatched successfully while the error page is not getting dispatched at all . . PLEASE HELP ME !!
It would be highly appreciated if you could kindly help me overcome this NullpointerException . Thanks A Lot in Advance !!
Regards,
Kasiraj