Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet not running

 
S. Dave
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
by doing so neither my jsps are working nor the servlet.
 
Yellaiah Gopireddy
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
S. Dave
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
they are inside DatePrj directory. lying parallel to the web-inf directory.
 
S. Dave
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With this above directory structure, my servlet is still not working
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
S. Dave
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did restart my server after moving/changing files/folders.
[ October 18, 2008: Message edited by: S. Dave ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic