Two Laptop Bag*
The moose likes Servlets and the fly likes Servlet not running Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet not running" Watch "Servlet not running" New topic
Author

Servlet not running

S. Dave
Greenhorn

Joined: Oct 18, 2008
Posts: 7
Servlet not running. giving 404 error. The requested resource (/DatePrj/tdyDate) is not available.
classpath is set properly. Tried running servlet with invoker. It is running fine that way. but with this web.xml tht I wrote, its not working. Please tell me what m i doing wrong.

Directory structure

Tomcat 5.5
|
webapps
|
ROOT
|
DatePrj
|
WEB-INF JSPs HTMLs
|
classes web.xml
|
web
|
dateServlet.class
----------------------
dateServlet.Java

----------------
web.xml

--------------------
http://localhost:8080/DatePrj/tdyDate
[ October 18, 2008: Message edited by: S. Dave ]

S. Dave
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by Sukanya Shah:

Directory structure

Tomcat 5.5
|
webapps
|
ROOT|
DatePrj
|
WEB-INF
|
classes -- web.xml
|
web
|
dateServlet.class

----------------------------------



http://localhost:8080/DatePrj/tdyDate



put your DatePrj under the webapps directly... here what is the need of ROOT?
S. Dave
Greenhorn

Joined: Oct 18, 2008
Posts: 7
by doing so neither my jsps are working nor the servlet.
Yellaiah Gopireddy
Greenhorn

Joined: Mar 24, 2007
Posts: 12
Tomcat 5.5
|
webapps
|
DatePrj
|
WEB-INF
|
web.xml
classes
|
web
|
dateServlet.class

is this looks like your folder structure??If no,put your folder structure like this.
[ October 18, 2008: Message edited by: Yellaiah Gopireddy ]
S. Dave
Greenhorn

Joined: Oct 18, 2008
Posts: 7
I tried doing this too, placed DatePrj Folder out of the ROOT, but its not working. Giving the same error. Plus now even the jsps are not working.


Arent we supposed to place the content in tomcat/webapps/ROOT/ ? I read in the tomcat tutorial that webapps/ROOT/ is where we place our jsp files to run them.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by S. Dave:
I tried doing this too, placed DatePrj Folder out of the ROOT, but its not working. Giving the same error. Plus now even the jsps are not working.


then,where you placed your jsp?

s.Dave:
-----------------------------------
Arent we supposed to place the content in tomcat/webapps/ROOT/ ? I read in the tomcat tutorial that webapps/ROOT/ is where we place our jsp files to run them.
--------------------------------

ROOT is a web application directory which is used by tomcat

if we create our own web application we must place it under the webapps directory only
[ October 18, 2008: Message edited by: seetharaman venkatasamy ]
S. Dave
Greenhorn

Joined: Oct 18, 2008
Posts: 7
posted Today 1:58 AM
--------------------------------------------------------------------------------
Tomcat 5.5
|
webapps
|
DatePrj
|
WEB-INF - jsps and htmls
|
web.xml
classes
|
web
|
dateServlet.class


Are they correctly placed ? If yes, why arent they working ?
http://localhost:8080/DatePrj/registerForm.html (form calls a jsp)
[ October 18, 2008: Message edited by: S. Dave ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
JSP and HTML pages need to be in the "DatePrj" directory, not in WEB-INF. Nothing that's inside of WEB-INF will be served to a client.


Ping & DNS - my free Android networking tools app
S. Dave
Greenhorn

Joined: Oct 18, 2008
Posts: 7
they are inside DatePrj directory. lying parallel to the web-inf directory.
S. Dave
Greenhorn

Joined: Oct 18, 2008
Posts: 7
With this above directory structure, my servlet is still not working
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Originally posted by S. Dave:
With this above directory structure, my servlet is still not working


Did you shutdown the server and restart it after moving the files?


Steve
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the .


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
S. Dave
Greenhorn

Joined: Oct 18, 2008
Posts: 7
I did restart my server after moving/changing files/folders.
[ October 18, 2008: Message edited by: S. Dave ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

Originally posted by S. Dave:
Arent we supposed to place the content in tomcat/webapps/ROOT/ ? I read in the tomcat tutorial that webapps/ROOT/ is where we place our jsp files to run them.
No, that's just bunching them up into the already-existing Tomcat example application.

It'd be better to create your own context.

Have you read the portions of the Servlet Specification that deal with proper structure of web apps?
[ October 18, 2008: Message edited by: Bear Bibeault ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet not running