aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes beer app not running Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "beer app not running" Watch "beer app not running" New topic
Author

beer app not running

vaibhav mishra
Ranch Hand

Joined: Jun 18, 2008
Posts: 168
I have created a small app as given in HFSJ Ch.3

I was able to display html form then suddenly due to some misconfiguration or something
the app start giving 404 error
attached is my app directory structure , tomcat is running fine

here is web.xml




I reinstalled tomcat and again do all the steps, I put form.html in webapps folder and put class and stuff in WEB-INF folder , but I didn't put web.xml there(I forgot to do so)
then first time form.html loads and on submit it says /Selection.do (fair enough)
but then when I again reload form.html it gives 404 error

Kindly help me out


[Thumbnail for webapps.png]


SCJP
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

And what happens if you remove the space in the servlet name?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Omar Al Kababji
Ranch Hand

Joined: Jan 13, 2009
Posts: 357
And what happens if you remove the space in the servlet name?


servlet-names can have spaces there is no problem to add spaces in your servlet names.


your closing tag <web-app> should be </web-app> may be this would resolve your problems


Omar Al Kababji - Electrical & Computer Engineer
[SCJP - 90% - Story] [SCWCD - 94% - Story] [SCBCD - 80% - Story] | My Blog
vaibhav mishra
Ranch Hand

Joined: Jun 18, 2008
Posts: 168
I did it ( although HFSJ have a space ) and no luck
I also fixed the lack of slash in closing servlet-mapping tag and web-app

new web.xml is


even form.html is not loading



Omar Al Kababji
Ranch Hand

Joined: Jan 13, 2009
Posts: 357
I put form.html in webapps folder and put class and stuff in WEB-INF folder , but I didn't put web.xml there(I forgot to do so)



you should have a directory in your webapps with a name for you web application for example "myWebApp" and then when you call form.html you should call
http://localhost:8080/myWebApp/form.html

your structure should be like this


Jonathan Elkharrat
Ranch Hand

Joined: Dec 31, 2008
Posts: 170

what's the link you see on the browser when you get the 404 error?


SCJP 5, SCWCD 5, SCBCD 5
vaibhav mishra
Ranch Hand

Joined: Jun 18, 2008
Posts: 168
@omar


Yes I do have a directory named Beer-v1 in which I have those


@Jonathan

This is the link
http://localhost:8080/Beer-v1/form.html
Jonathan Elkharrat
Ranch Hand

Joined: Dec 31, 2008
Posts: 170

i meant AFTER you submit the form, what's the URL?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

omar al kababji wrote:you should have a directory in your webapps with a name for you web application for example "myWebApp" and then when you call form.html you should call
http://localhost:8080/myWebApp/form.html

your structure should be like this



If you look at the image included in the start post you'll see that the application name is beer and that the files are all in the right place.

Besides the link, what is in the output and error logs of your Tomcat? A 404 error for static content could indicate an error in your web.xml
vaibhav mishra
Ranch Hand

Joined: Jun 18, 2008
Posts: 168
This is my current web.xml



@Jonathan

I cannot submit the form, and that static form.html is having 404 error

I am having same exact configuration as given in book.


Omar Al Kababji
Ranch Hand

Joined: Jan 13, 2009
Posts: 357
your form.html file is inside the WEB-INF directory this is wrong it should be raised up by one level, it should be a sibling for the WEB-INF directory ;). compare my file structure and yours again.
Jonathan Elkharrat
Ranch Hand

Joined: Dec 31, 2008
Posts: 170

then the most obvious answer is that your application isn't deployed.
check the log of tomcat (in logs folder of tomcat, the last modified)
to see what's the problem.
besides, maybe it's the hyphen (-) that doing this problem, try deploying
the application without the hyphen (Beer_v1 for example)
vaibhav mishra
Ranch Hand

Joined: Jun 18, 2008
Posts: 168
Edit:Got it running finally

it seems that web.xml was corrupted somehow,

I redo all the modifications again and it is running fine showing off the output
Thanks guys for hearing me out


original message:

omar al kababji wrote:your form.html file is inside the WEB-INF directory this is wrong it should be raised up by one level, it should be a sibling for the WEB-INF directory ;). compare my file structure and yours again.


it's a sibling , the picture showed it that way.
and here is my 404 error which I received previously, but all is working fine now

@Jonathan

HFSJ clearly show a hyphen, so I think it should not be a problem


[Thumbnail for 404.png]

Jonathan Elkharrat
Ranch Hand

Joined: Dec 31, 2008
Posts: 170

oh, yeah.
your webapp folder should be named "Beer-v1", not "MyWebApp"!!
vaibhav mishra
Ranch Hand

Joined: Jun 18, 2008
Posts: 168
Thanks Jonathan but myWebApp folder is of Jonathan my folder is named Beer-v1 and my code is up and running, thanks for helping me out.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

vaibhav mishra wrote:it seems that web.xml was corrupted somehow


Rob Prime wrote:Besides the link, what is in the output and error logs of your Tomcat? A 404 error for static content could indicate an error in your web.xml

* does a little victory dance * ;)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: beer app not running