GeeCON Prague 2014*
The moose likes IDEs, Version Control and other tools and the fly likes Servlet HTML form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Servlet HTML form" Watch "Servlet HTML form" New topic
Author

Servlet HTML form

Greg Bag
Ranch Hand

Joined: Dec 25, 2010
Posts: 52
Hey guys i have a problem and I have tried several times to solve it. Here is the scenario. I created a student registration HTML file and a servlet to answer this file. The problem is the submit button doesn't work on the html form. I have tried dozens and dozens of ways to put the right "action =path" but it doesn't work. This is what I did step-by-step.

In NETBEANS 6.9.1

1) Create new web application project.
2) Under source packages, I created a new Chapter39 package.
3) After that, I right-clicked the chapter39 package and created a HTML form and a java servlet.
4) After creating both, I right clicked the HTML form and clicked "VIEW"
5) I entered the information into the html form and when I clicked submit, it said "FILE NOT FOUND". When I went to the location of the file, it was there. So I don't understand.... what's going on.

HERE IS THE HTML CODE.



AND HERE IS THE SERVLET CODE



HERE IS THE web.xml



Please just tell me what I must put for the "ACTION = " in the html form.
I have tried .....
action = "getStudentInfo"
action = "/getStudentInfo"
action = "/servlet/getStudentInfo"

None of these work. Please guys help me out.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Please read this: ItDoesntWorkIsUseless. Also, we don't know whether that HTML code was served from your web application or from somewhere else. Its base URL is important information which you didn't provide.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61317
    
  66

You need the context path as a prefix. This can be fetched via ${pageContext.request.contextPath}.

More info in the JSP FAQ.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Greg Bag
Ranch Hand

Joined: Dec 25, 2010
Posts: 52
Here is the base URL for the html
The file is saved on my USB drive.
file:///K:/Web%20Programming/Servlets/IntroToServlets/src/java/Chapter39/StudentRegistration.html

This is the URL for the servlet
http://localhost:8084/getStudentInfo

Also before creating the project, I remember seeing a context path: /IntroToServlets which is also my project name
So I did action = "/IntroToServlets/getStudentInfo" and it still says file not found.

Also, both the HTML file and the servlet.java are found in the same folder.
K:\Web Programming\Servlets\IntroToServlets\src\java\Chapter39
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61317
    
  66

As you seem umbilicalled to the IDE, I've moved this along to the IDEs forum.
Greg Bag
Ranch Hand

Joined: Dec 25, 2010
Posts: 52
Well I figured it out myself without your help, thanks anyways Mr. Umbilicalled.
 
GeeCON Prague 2014
 
subject: Servlet HTML form