Ashutosh_shukla
Ashutosh_shukla
Branch Unspecified
13 Dec 2008

Servlets not running

Can you please tell my servlets are not running?
I have J2SE and J2EE installed on my machine.
I have apache tomcat 6.0.18 installed as well.
I think may be i have set the wrong paths.
I want to know all details about the paths to be set for the servlets.
Can anyone help please thanks in advance.
i am 😔😔😔😔😔 make me 😀😀😀😀😀
mi_pratik

mi_pratik

Branch Unspecified
14 Dec 2008

https://pdf.coreservlets.com/
Check this site

I did a lot time ago that really helped in the servlets part a lot
Ashutosh_shukla

Ashutosh_shukla

Branch Unspecified
14 Dec 2008
I will check it thanks but any further help is welcome
shalini_goel14

shalini_goel14

Branch Unspecified
15 Dec 2008
Hi Ashutosh,
Please confirm if your following classpaths are set properly or not:

1. Default location for tomcat installed is "C:\ProgramFiles\Apache Software Foundation\Tomcat 6.0"

If it is other than this
set JAVA_HOME environment variable to <directory in which Java is intalled>
Default directory for java installed is "C:\Program Files\Java\JDK1.6"

2. Confirm if lib folder of tomcat contains servlet.jar
"C:\ProgramFiles\Apache Software Foundation\Tomcat 6.0\common\lib" folder contains servlet.jar .This jar file is required for running servlets.

3. Check if "C:\ProgramFiles\Apache Software Foundation\Tomcat 6.0\common\lib\servlet.jar" is included in your CLASSPATH environment variable.Because classes required for running your servlet class can be find from here.

4. Make sure the class file of your servlet java class exist in tomcat's webapps directory.

5. Appropriate entry is made in web.xml

Hope,this info will help you somewhere 😀.

If still any problem exist,better you show us error-logs or setting you have made in your local machine.
Ashutosh_shukla

Ashutosh_shukla

Branch Unspecified
21 Dec 2008
I have not written any web.xml file can you please help me out with that one I am giving you my servlet code enclosed here in.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class abc extends HttpServlet
{
	public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
	{
		PrintWriter out=response.getWriter();
		String title="Simple Servlet Output";
		response.setContentType("text/html");
		out.println("<html><head><title>"+title+"</title></head>");
		out.println("<body><h1>"+title+"</h1>");
		out.println("Hello</body></html>");
		out.close();
	}
}
I want to know is there any way to check the servlet code without writing the web.xml file each time.confused:
shalini_goel14

shalini_goel14

Branch Unspecified
21 Dec 2008
Hi Ashutosh,

If your above code is not giving any compiler errors,then its ok.But you have to make an entry in web.xml.

 
<servlet>
<servlet-name>abc</servlet-name> 
<servlet-class>abc</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>abc</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
I hope u understand how important this entry is 😀. Any doubts please specify clearly.
Ashutosh_shukla

Ashutosh_shukla

Branch Unspecified
22 Dec 2008
Hello, thanks that you are helping but the error is that it cannot find the servlet classes so may be i have set the wrong paths I have checked all the paths they are set as per your saying can you just check my code if it is correct by running it on your platform if possible.I am sick of this error will keep trying to check all paths again but its tuff to find your own errors.Anyways please tell me if code is correect.
shalini_goel14

shalini_goel14

Branch Unspecified
22 Dec 2008
Hi Ashutosh,

Your code is absolutely fine.Right now I cannot run it on my system.Have you put the abc.class file in webapps folder of apache tomcat ? If not Please create some folder for eg. servletTest in webapps and in it create one WEB-INF folder and inside WEB-INF create one classes folder .Put your abc.class file there.Also create one web.xml in WEB-INF folder.Once done start the server, open the browser enter the correct url then you will get a page displaying what you tried to print from abc.java file.

If you can get Complete Reference of Java from someone ,better read its Servlet chapter(I guess some 29th-30th chapter in j2se5 edition) . It will definitely solve your problem 😀.

PS: A suggestion Please never make a class like 'abc' in java .Its first letter should be always capital.You could make ServletTest.java.
Ashutosh_shukla

Ashutosh_shukla

Branch Unspecified
23 Dec 2008
Ya i know the naming conventions of Java but the point is not that. I will refer the Complete Reference for help for sure I have a copy of that.Anyways I executed the program on a friends machine I got it sorted out.Thanks for all your help.
shalini_goel14

shalini_goel14

Branch Unspecified
24 Dec 2008
Welcome 😀. Please share your actual problem and its solution here.
cse_200509

cse_200509

Branch Unspecified
03 Jan 2009
well !!!
one thing that is missing is that u need to add an entry for your servlet in
/tomcat/webapps/examples/WEB-INF/web.xml .
an entry like this is required:

<servlet>
<servlet-name>YourServlet</servlet-name>
<servlet-class>YourServlet</servlet-class>
</servlet>
nileshchakkar

nileshchakkar

Branch Unspecified
04 Jan 2009
very good descussion by all of you.
Thanks a lot

Share this content on your social channels -

Only logged in users can reply.