• 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

Not able to run sample servlet + jsp

 
Ranch Hand
Posts: 114
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all I am trying to run sample servlet with jsp ,first i need to display the jsp page and then when user clicks on button the form parameters needs to be passed to the servlet which is given in jsp page using action in form tag.Below are my codes,please help me regarding this

jsp page


SampleServlet


web.xml

when i tried url http://localhost:8080/<appl-name>; then its displaying the default test.jsp page when i click on submit button its not at all responding and not giving any error,any idea what is the problem
 
Saloon Keeper
Posts: 7582
176
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're assuming that the URL format of the HTML form action attribute and the web.xml url-pattern are identical - but they're not. The former needs to include the web app context name, whereas the latter does not. This may help: https://coderanch.com/how-to/java/RelativeLinks
 
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you also have a problem with the attributes of your textarea. Only form elements with a "name" attribute will be submitted for form processing, not the "id" attribute. Use Firebug to look at the parameters being sent to the server on the submit. I think you'll find that nothing is being sent.
 
Vas Miriyala
Ranch Hand
Posts: 114
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your replies I just added below line of code in jsp page,then also its not able to map the action to servlet
 
Tim Moores
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vas Miriyala wrote:its not able to map the action to servlet


What does that mean? What, exactly, happens if you click the submit button? Note that the button is not of type "submit", so it won't by itself submit the form.
 
J. Kevin Robbins
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A button of "type=button" doesn't do anything without Javscript watching for a click event. I think you are looking for type=submit.

Also, instead of scriptlet code use action="${pageContext.request.contextPath}/hello". You really want to learn to use JSTL and EL and avoid scriptlets.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just replace the tag as
<form action="hello" method="POST".......>
then
<textarea ........ name="name">
and then
<input type="submit" name="submit">
and check it...
and try to cast the parameter as
String enteredtext =(String) request.getParameter("name");
 
Vas Miriyala
Ranch Hand
Posts: 114
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to every one...I really appreciate your help..Now its working Fine
 
reply
    Bookmark Topic Watch Topic
  • New Topic