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
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
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.
"There is no reason for any individual to have a computer in his home" ~ Ken Olson, Co-founder of DEC, 1977
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
Rancher
Joined: Sep 21, 2011
Posts: 2407
posted
0
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.
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.
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");