• 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

404 error

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm just starting out with JSP's and servlets.

I'm the latest Tomcat container.

I'm trying to set up a simple login example (taken from O'reilly's ONJAVA pages)

Here is my web.xml entry:


I would like to access my login.class servlet from my login.jsp page.

Here is the <FORM> entry of my login.jsp page:



My form has a SUBMIT button. When I press it I am expecting my servlet to get executed, but instead, I get a 404 error:



Any idea what I could have done wrong here?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by jeff ukridge:

...



The servlet name and the form's "action" (both in bold here) need to match. The form should change to use "login" as the action.
 
jeff ukridge
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the response. Unfortunately it didn't change the error:



Here is my directory structure in my TOMCATHOME/webapps:

in webapps/WRNR:



in the WEB-INF:


And then in classes there are furthere subdirectories:
/com/WRNR

and finially in WRNR is my class:





I was thinking that it could be a permissions problem?

Or maybe I need my web.xml file modified to include a <servlet-mapping> tag?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll need to create a servlet-mapping entry in your web.xml file.

Check out this thread.
I just posted an example web.xml file with a servlet-mapping to it.
https://coderanch.com/t/361660/Servlets/java/call-servlet
 
jeff ukridge
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm new to this so I'm a little confused.

What would my <servlet-mapping> look like?

Like this maybe:



I'm not sure that's right...

how about something like this:




I'm not at my system right now, or I would give these a try. I'll be at my system again in a few hours.
 
jeff ukridge
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
nothing changing here..I still can't get rid of the 404 error.

Here is the current state of the project.

In TOMCAT_HOME/conf/server.xml:



in TOMCAT_HOME/webapps/WRNR/login.jsp:




in TOMCAT_HOME/webapps/WRNR/WEB-INF/web.xml:



My servlet is in TOMCAT_HOME/webapps/WRNR/WEB-INF/classes/com/WRNR


And the error is:


I've tried many different permutations here. Does anyone see an error anywhere?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And what are you using for the form action now?
 
jeff ukridge
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok...2 days later, it seems as if the smoke has cleared.

My problems turned out to be that I had a mistake in my web.xml file.

Also ( I think ) that I needed to use the manager/html application to restart my servlet after I modified the web.xml.


Anyway, clearly my biggest mistake was to not include my complete web.xml to this forum. Somone would have seen a typo there a lot faster than I did.
 
How do they get the deer to cross at the signs? Or to read this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic