File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Servlet to JSP communication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet to JSP communication" Watch "Servlet to JSP communication" New topic

Servlet to JSP communication

Sanjay, Lalwani

Joined: Jun 05, 2001
Posts: 4
Is there any one who has solved problem of communicating info from servlet to jsp.
Poornima Shetty

Joined: Dec 12, 2000
Posts: 26
Whats it that you would like to know?
Glenn Proctor

Joined: Jun 07, 2001
Posts: 1
Depending on the detail of your application, you can probably use the session object.
Ranch Hand

Joined: Apr 18, 2001
Posts: 46
There is not much diffrenece in what you do for servlet-servlet communication and the servlet-jsp communication. Only thing you need to consider is the path and the port.
Originally posted by Sanjay, Lalwani:
Is there any one who has solved problem of communicating info from servlet to jsp.

Vikas Aggarwal
Technology Associate

Vikas Aggarwal<BR>Technology Associate<BR>
Melissa Rabin

Joined: May 30, 2001
Posts: 3
Struggling with this a few weeks ago myself (being the greenhorn of servlets that I am), i learned that there are several tasks involved in communicating jsp info to a servlet:
1. Access web data through the request object of a servlet. Strings can be retrieved through get/setParameter, and objects via get/setAttribute(). Add/manipulate them via your session context object when in the servlet doPost method.
2. Don't forget, if you use servlets in your web apps you need to provide a declaration and mapping for them in your web deployment descriptor (your web.xml). This is a twofold task of declaring the servlet (and its class package) in the <servlet> element, and mapping the servlet to a url pattern (i.e. the initiating jsp) in the <servlet-mapping> element. Your web app container should provide ample info on the details.
3. Include the tag
<form name = "ServletName" action="/ServletName" method = "POST">
and you will be ready to go!
Hope this helps!
I agree. Here's the link:
subject: Servlet to JSP communication
It's not a secret anymore!