This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

form data not passing to servlet file

 
tushar panda
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i tried to create a html form to submit a value to a servlet.

Html file : threeparamform.html (code below)




servlet file : threeparam.java (code below)



both "form-data" & "WEB-INF" are in same root directory , html file is in form-data directory , java file in WEB-INF directory.

my problem is on clicking submit button data is not submitted ..why so ??
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What actually happens?

Is your servlet code in a package?

Are there any relevant messages in the server log files>

Bill
 
tushar panda
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What actually happens?


the page does not chages , which means data not submitted

Is your servlet code in a package?


no it is not in a package

Are there any relevant messages in the server log files


here are those :


i put all the log here as i cannot understand which part to copy ...


 
anilkumar patil
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you need to add the entry of the servlet to your web.xml .

<servlet>
<servlet-name>threeparam</servlet-name>
<servlet-class>Threeparam</servlet-class>
</servlet>

<servlet-class> - fully qualified class name. No package is mentioned as you said your servlet does not reside in any package.I feel you should add your servlet to a package and add the full package name to this parameter. Keeping your servlets in WEB-INF is not a good practise.

you then need to have a servlet mapping , similar to the one given below.
.
.
<servlet-mapping>
<servlet-name>threeparam</servlet-name>
<url-pattern>/threeparam</url-pattern>
</servlet-mapping>

<url-pattern> - This is what the html file should refer to .

You also need to make a change to you html file. Please change ACTION="/servlet/threeparam" to ACTION="threeparam" .

tks

 
tushar panda
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
andy asd wrote:
<servlet-mapping>
<servlet-name>threeparam</servlet-name>
<url-pattern>/threeparam</url-pattern>
</servlet-mapping>

<url-pattern> - This is what the html file should refer to .
You also need to make a change to you html file. Please change ACTION="/servlet/threeparam" to ACTION="threeparam" .



i have changed accordingly , in the url pattern i have given full pathname , but the values are not passed , previously nothing was happening now after following your instructions threeparam.java is displayed but the values of first,second , third parameter are null. the values are not getting passed . so where lies the problem..

which web.xml file should i change the one in "WEB-INF" or the one in "conf"

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65114
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you have two web.xml files?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tushar panda wrote:which web.xml file should i change the one in "WEB-INF" or the one in "conf"

?! You should change the one for your webapp--the one in <tt>WEB-INF</tt>.
 
tushar panda
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Why do you have two web.xml files?


the first "web.xml" is inside conf but another one automatically got created and is in WEB-INF .

contents of the second one :
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65114
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The one in conf is superfluous. Only the one in WEB-INF matters.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic