• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not able to run sample servlet + jsp

 
Vas Miriyala
Ranch Hand
Posts: 114
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • 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
 
Tim Moores
Bartender
Posts: 2839
46
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: http://www.coderanch.com/how-to/java/RelativeLinks
 
J. Kevin Robbins
Bartender
Pie
Posts: 1793
20
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • 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 Java Spring
  • Mark post as helpful
  • send pies
  • 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
Bartender
Posts: 2839
46
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 1793
20
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.
 
sridhar sivaraman
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • 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 Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to every one...I really appreciate your help..Now its working Fine
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic