Hello friends ,
I am unable to get rid of confusion related to getContext() method of ServletContext interface.
I am using
Tomcat 5.0
WebApplication : myProject
--
Servlet : NamedDispatcher.java
In this servlet I wrote the following code in the service method
ServletConfig sg=getServletConfig();
ServletContext sc=sg.getServletContext();
if(sc==null)
{
System.out.println("sc is null");
}else
{
System.out.println("sc is not null"); // -------------------------- Line 1
ServletContext newsc=sc.getContext("/NewProject");
if(newsc==null)
System.out.println("newsc is null"); //----------------------------Line 2
else
{
newsc.getRequestDispatcher("/New.jsp").forward(request,response);
return;
}
}
Now I created another Webapplication in webapps directory
WebApplication : NewProject
--
JSP : New.jsp
In this JSP file I wrote the following code
<html>
<body>
<form name=ultra>
<input type=Textbox name=user size=3 maxlength=3>
<input type=button value=Enter>
</form>
</body>
</html>
When I access this JSP file using the following URL then I am able to see the user Interface
http://localhost:8080/NewProject/New.jsp In the server.xml file present in the conf directory I made the following settings
<Context path="/myProject" docBase="D:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\myProject" crossContext="true" debug="0" reloadable="true" privileged="true"/>
<Context path="/NewProject" docBase="D:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\NewProject" crossContext="true" debug="0" reloadable="true" privileged="true"/>
But despite making these changes I am unable to see the JSP file of NewProject webapplication !!
I get the error as
Dec 23, 2004 7:26:00 PM org.apache.jasper.runtime.JspFactoryImpl internalGetPageContext
SEVERE: Exception initializing page context
java.lang.NullPointerException
The only output that I can see on the tomcat console is the "Line 1" indicated above.
I dont see "Line 2" on the tomcat console.
Can anyone please help me out of this problem ?
Waiting for reply,
Thanks and Regards
Rohit.