1. Home >
  2. Apps >
  3. Groups >

Servlets not running

Question asked by Ashutosh_shukla in #Coffee Room on Dec 13, 2008
Ashutosh_shukla 路 Dec 13, 2008
Rank D1 - MASTER
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 😀😀😀😀😀 Posted in: #Coffee Room
mi_pratik 路 Dec 14, 2008

Check this site

I did a lot time ago that really helped in the servlets part a lot
Ashutosh_shukla 路 Dec 14, 2008
Rank D1 - MASTER
I will check it thanks but any further help is welcome
shalini_goel14 路 Dec 15, 2008
Rank A3 - PRO
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
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 路 Dec 21, 2008
Rank D1 - MASTER
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";


"); out.println("Hello"); 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 路 Dec 21, 2008
Rank A3 - PRO
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.




I hope u understand how important this entry is 馃榾. Any doubts please specify clearly.
Ashutosh_shukla 路 Dec 22, 2008
Rank D1 - MASTER
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 路 Dec 22, 2008
Rank A3 - PRO
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 路 Dec 23, 2008
Rank D1 - MASTER
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 路 Dec 24, 2008
Rank A3 - PRO
Welcome 馃榾. Please share your actual problem and its solution here.
cse_200509 路 Jan 3, 2009
Rank D3 - MASTER
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:

nileshchakkar 路 Jan 4, 2009
Rank D1 - MASTER
very good descussion by all of you.
Thanks a lot

You must log-in or sign-up to reply to this post.

Click to Log-In or Sign-Up