I am using the html form for the input and using the servlet class in the tomcat container I want to get the attribute from the html and then the result will be displayed in the jsp page , I am beginner so please guide me for the solution.
First, here's a useful tip for making your posts easier to read. Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extermely hard to read and most people will just go elsewhere. Please read this for more information.
You can go back and change your post to add code tags by clicking the .
I am using the html form for the input and using the servlet class
And yet, your form action is:
To invoked the servlet, you need to use the mapping that you set up in the deployment descriptor (web.xml).
In this case that's:
(I'd come up with a better name than xyz!)
So your form action should be:
This assumes that your web application is the ROOT web app. Otherwise, you need to prefix the mapping with the context root. You'll need to let us know whether your application is the ROOT or not.
Also, I notice that your servlet class is not in a package. This will cause you trouble. Be sure to place all your Java classes in a package other than the default.
Hi, you have to redirect your request from servlet to jsp using RequestDispatcher's object include or forward method.you can set attributes in request object, and retrive them in jsp.
Originally posted by Bear Bibeault: Welcome to the Ranch.
First, here's a useful tip for making your posts easier to read. Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extermely hard to read and most people will just go elsewhere. Please read this for more information.
You can go back and change your post to add code tags by clicking the .
Hi Bear Bibeault ,
Thank you very much for your reply and for the basic infomation inside javaranche.
Regarding the code i even changed i.e. i gave post="/url-pattern" inside the html file but still it is not working.
I tried all the possible but still there is some problem between the sevlet and the Jsp.
I wasn't suggesting that you put the full path in your form. I just wanted you to post it here so we can see what it is. Your application is not the root application in your server. It has a contextPath of "Lasto". Therefore, Lasto needs to be part of your URL when calling your servlet.
I wasn't suggesting that you put the full path in your form. I just wanted you to post it here so we can see what it is. Your application is not the root application in your server. It has a contextPath of "Lasto". Therefore, Lasto needs to be part of your URL when calling your servlet.
I kept in the form action="Lasto/xyz" ....
and when i enter some text in the form , i can see that jsp excutes but i am getting only a blank page, there is no display of any string which i enter in the html nor some text inside the JSP.
Originally posted by Ben Souther: There's nothing missing as far as the attribute goes. You're binding it to request scope. Your JSP is reading it back from session scope.
What's missing is the forward from the servlet to the JSP.
Download the SimpleMVC example in our code barn. Drop the war file in your webapps directory and Tomcat will deploy it.
You will then have a working example that does all of this.
Hi,
I used the example which you mentioned and added the requestdispatcher in the servlet and now its working.
Thanks a lot
Any good suggestion from you to me, after seeing my errors , as i want to be a good programmer.
Originally posted by sachin mesala: Any good suggestion from you to me, after seeing my errors , as i want to be a good programmer.
Yes. Pick up a good book on the subject. I used Core Servlet and Java Server Pages years ago. I know there is a newer edition of it out there but haven't looked at it yet. Another one that is popular is the Head First Servlets book.
Yes. Pick up a good book on the subject. I used Core Servlet and Java Server Pages years ago. I know there is a newer edition of it out there but haven't looked at it yet. Another one that is popular is the Head First Servlets book.