Hi all,
I am using package in my
servlets, the folder structure for the same package looks like the following:
D:Servlets\Mypackage\coreservlets
in coreservlets directory, I have two folders as, Application and Helpers
in Application folder I have the following servlet code:
package coreservlets.Application;
import coreservlets.Helpers.ServletUtilities;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
import java.io.PrintWriter;
public class HelloWWW3 extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response. getWriter();
out.println(ServletUtilities.headWithTitle("Hello WWWW")+"<body>Hello</body></html>");
}
}
in Helpers folder I have the following servlet code:
package coreservlets.Helpers;
public class ServletUtilities
{
public static
String headWithTitle(String title)
{
return ("<html><head><title>"+title+"</title></head>");
}
}
Settings in web.xml is as follows:
<servlet>
<servlet-name>HelloWWW3</servlet-name>
<servlet-class>HelloWWW3</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWWW3</servlet-name>
<url-pattern>/HelloWWW3</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>ServletUtilities</servlet-name>
<servlet-class>ServletUtilities</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletUtilities</servlet-name>
<url-pattern>/ServletUtilities</url-pattern>
</servlet-mapping>
I am using
Tomcat 5.0 server, and for coding purpose I am using IntelliJIdea 3.0.5
when I compile these two programs it creates folder structure as coreservlet\Application\HelloWWW3.class and coreservlet\Helpers\ServletUtilities.class in C:\Tomcat 5.0\webapps\Mysite\WEB-INF\classes path....that is ok!!!
I run servlet in Internet Explorer as
http://localhost:8080/Mysite/coreservlets.HelloWWW3 I have also tried
http://localhost:8080/Mysite/Application.HelloWWW3 but, it's not working by giving me error as "The requested resource (/Mysite/coreservlets.HelloWWW3) is not available."
Could anyone explain me what I am doing wrong..???...
Thanx in advance
Pravin