• 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

Servlet HTML form

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well I figured it out myself without your help, thanks anyways Mr. Umbilicalled.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic