Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

form data not passing to servlet file  RSS feed

 
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 ??
 
Author and all-around good cowpoke
Posts: 13078
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 ...


 
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"

 
Sheriff
Posts: 67261
170
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?
 
Author
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
Sheriff
Posts: 67261
170
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.
 
Skool. Stay in. Smartness. Tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!