File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet HTML form

 
Greg Bag
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20170
24
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need the context path as a prefix. This can be fetched via ${pageContext.request.contextPath}.

More info in the JSP FAQ.
 
Greg Bag
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As you seem umbilicalled to the IDE, I've moved this along to the IDEs forum.
 
Greg Bag
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I figured it out myself without your help, thanks anyways Mr. Umbilicalled.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic