• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

beer app not running

 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
webapps.png
[Thumbnail for webapps.png]
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And what happens if you remove the space in the servlet name?
 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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

 
vaibhav mishra
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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


 
Ranch Hand
Posts: 170
Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what's the link you see on the browser when you get the 404 error?
 
vaibhav mishra
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@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
Posts: 170
Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i meant AFTER you submit the form, what's the URL?
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 170
Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
404.png
[Thumbnail for 404.png]
 
Jonathan Elkharrat
Ranch Hand
Posts: 170
Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh, yeah.
your webapp folder should be named "Beer-v1", not "MyWebApp"!!
 
vaibhav mishra
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 * ;)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic