Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

HFSJ Help

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I am new to this forum and also to servlets and jsp...i have completed SCJP 1.4 and currently trying to prepare for SCWCD.I am following HFSJ.I was trying to write,deploy and run the sample servlet in chapter 1 pg:30. i have done everything as mentioned ,i had a few problems and now i have fixed everything,tomcat is properly installed,i can compile the servlet and now i am trying to display it in the brower but it keeps saying page cannot be found.I have rechecked everything mentioned in the book.As i am a stranger to servlets i though some one in this forum could help.

Meenakshi
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Meenakshi,

Check your web.xml document and make sure that you have the correct name for the <servlet-class> element. This name should match the source file name without the extension.

Also, you can open a browser and type - http://localhost. If you see tomcat's home page, then u can be sure that it is running properly.

Just shut down tomcat and start it again and try it.
 
Meenakshi Lakshmanan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you krithika

I double checked my xml file as you had suggested still its not working...tomcat is working fine it displays the tomcat welcome page when i type http://localhost:8080/ in my web browser.

cant figure out what is wrong
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are many reasons why you could not access your page.
An obvious one would be concerning your servlet mapping.

How did you set the mapping in web.xml (<servlet-mapping>),
and how are you trying to access your page (in the browser address bar) ?
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Meenakshi Lakshmanan:
Hello

I am new to this forum and also to servlets and jsp...i have completed SCJP 1.4 and currently trying to prepare for SCWCD.I am following HFSJ.I was trying to write,deploy and run the sample servlet in chapter 1 pg:30. i have done everything as mentioned ,i had a few problems and now i have fixed everything,tomcat is properly installed,i can compile the servlet and now i am trying to display it in the brower but it keeps saying page cannot be found.I have rechecked everything mentioned in the book.As i am a stranger to servlets i though some one in this forum could help.

Meenakshi




Hi Meenakshi

I Thinks i might solve your problem look i am writting the web.xml file content and crossed checked whether it is written in the same way or not. if not then change it as i mention in this post


<web-app>

<servlet>

<servlet-name>Internal</servlet-name>
<servlet-class>com.example.web.BeerSelect</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>Internal</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>

</servlet-mapping>

</web-app>

Secondly when you try to call your servlet through HTML Please check whether you have written it in the same way or some thing other.

<form method="Post" action="SelectBeer.do">

In action="/SelectBeer.do" is false use the above tag as i mentioned.
If not then tell me.


If not running then please send me the exact error displaying in your page.
So that i will look the actual error.
Thanks
Chidanand Chauhan
 
Meenakshi Lakshmanan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Chidanand

Thank you for your detailed reply. i am actually trying to run the very first program in HFSJ in page 30..i have not crossed that to come to the next example.

my xml file looks like this
<web-app xmlns="http://java.sun.com/xml/ns/j2ee";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
web-app_2_4.xsd"
version ="2.4">
<servlet>
<servlet-name>Chapter1 Servlet</servlet-name>
<servlet-class>Ch1Servlet</serlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Chapter1 Servlet</servlet-name>
<url-pattern>/Serv1</url-pattern>
</servlet-mapping>
</web-app>

and the error i am getting is

HTTP 404 - File not found

Just to be sure i also tried to look at the examples that comes with tomcat and the helloworldexample servlet works fine ...i think there is something wrong with my web.xml but i cant figure it out.please help
 
Meenakshi Lakshmanan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Satou

I am trying to access it in my browser address bar using

http://localhost:8080/ch1/Serv1

my servlet class is in c:\tomcat\webapps\ch1\WEB-INF\classes
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
change:

<web-app xmlns="http://java.sun.com/xml/ns/j2ee";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
web-app_2_4.xsd"

version ="2.4">

to:

<web-app xmlns="http://java.sun.com/xml/ns/j2ee";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
[ December 14, 2005: Message edited by: Vivaldo Pinto ]
 
K Bala
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Meenakshi,

If you copied and pasted the exact code from your web.xml file, then I found something.

In the "servlet" element, the closing tag of the servlet-class is spelled wrong. It is spelled as serlet-class. Correct this in your web.xml and copy the web.xml and paste it in the tomcat directory. Now restart your tomcat and try it. Let us know if it works.
 
Meenakshi Lakshmanan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you vivaldo now it works
Thanx Krithika for noticing the typo

Thanx to everyone who responded it helped.... now i can proceed

Meenakshi
 
Vivaldo Pinto
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
happinesses!!!
 
Chidanand Chauhan
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its nice that atlast your code runs........... Good done.
 
Ranch Hand
Posts: 167
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You can use this list of errors while reading the HFSJ book. The reason of your problem was mentioned in this list.
Cheers
 
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic