building a servlet (tomcat)?

hi to all
am using intellij 5.0.2 and installed tomcat 5 and i have been trying to figure how to make a simple servlet to run with no succes can anyone help me out tryed everything but nothing seems to work for me :(
thank you for the help

Comment actions Permalink

Please describe what exact steps you did.

Comment actions Permalink

If you're on windows: don't use the installer, but unpack the compressed archive instead. The start/stop scripts are missing from the installer bundle.

Comment actions Permalink

i have used the setup version of tomcat and i have fix my own bat files for the startup and shutdown of the server
and it worked .i made the java file and the wep.xml file everything seems ok,but what i dont get is do i have to edit the server.xml file for tomact to point out were my project files are ,cause when i run my project the server runs and then it starts a web page but 404 page not found.i dont get what am doing wrong
thank you for the help

Comment actions Permalink

the steps i took are
1- create new project
2-enter Project Name :Tut_1
3-enter project location :e:\servlet\Tut_1
3-select project jdk: 1.4 java
4-choosed single-mdoule project
5-select module typr: Web module
6-select mdoule name : Tut_1
7:module content root::e:\servlet\Tut_1
8:select application server:Tomcat
8-2:tomacat home:C:\Program Files\Apache Software Foundation\Tomcat 5.5
8-3:tomcat directory:C:\ProgramFiles\ApacheSoftwareFoundation\Tomcat 5.5
8.4:libaries:attached the classes of tomacat
9:deployment descriptors :checked web moduledeployment descriptor
10:setup web resource directory: checked
11specify web resource : e:\servlet\Tut_1\resources
12:relativa path in deployment derictory: \
13:setup web module exploded directory: checked
14:web module exploded directory: e:\servlet\Tut_1\exploded
15:creat a source directory ;checked
16:select compiler output path: e:\servlet\Tut_1\exploded\WEB-INF\classes
18:whent to j2ee project view and right clicked on the earch icon and choose new servlet
19:called the servlet name HelloServlet
20:placed this code in it:

  • import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;

public class Hello extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("Hello, world!");

21: the web.xml hs this in it:
HelloServlet HelloServlet ]]>

22:i bulied project
23:i press edit configure and shooce tomCat and add a new configure Local
24:application server i choosed tomcat nad cheacked open browser and startup page is http://localhost:8080/
24:deployment web module source i select exploded
25:application context: \
26:startup script i select the 2 bats for run and stop
27 uncheck pass enviroment variable

now when i try running it it shows server is starting up
connected and brings a browser up with 404 page not found
thats my foolish and long boring steps that lead nowere
thank you for the help

Comment actions Permalink

Add a servlet mapping to the web.xml file:


Then change the browser url to: http://localhost:8080/hello

Comment actions Permalink

i added the mapping and then ran the servlet a window poped out
with this in it:
HTTP Status 404 - /hello


type Status report

message /hello

description The requested resource (/hello) is not available.


Apache Tomcat/5.5.17

Comment actions Permalink

If you really set a backslash as context root in step 26, then please try to change it to a forward slash (/). If this still doesn't help, then you can send me your complete test project by mail. I'm quite sure there's just some simple configuration error.

Comment actions Permalink

ah atlast it worked
i changed the backslash,and placed the orginal bat files and it worked
thank you martin for all the help
here is what i had placed in the bat files which i was using

start: java -jar bootstrap.jar start
shutdown: java -jar bootstrap.jar stop


Please sign in to leave a comment.