aspose file tools*
The moose likes Servlets and the fly likes form data not passing to servlet file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "form data not passing to servlet file" Watch "form data not passing to servlet file" New topic
Author

form data not passing to servlet file

tushar panda
Ranch Hand

Joined: Feb 16, 2009
Posts: 133
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 ??


Do Right , Fear No Man
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12806
    
    5
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

Joined: Feb 16, 2009
Posts: 133
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

Joined: Jul 14, 2009
Posts: 5
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

Joined: Feb 16, 2009
Posts: 133
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

Joined: Jan 10, 2002
Posts: 61433
    
  67

Why do you have two web.xml files?

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Feb 16, 2009
Posts: 133
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

Joined: Jan 10, 2002
Posts: 61433
    
  67

The one in conf is superfluous. Only the one in WEB-INF matters.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: form data not passing to servlet file