Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP /Servlet - Printing issue

 
Saket Barve
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a JSP page which is using a Bean. The Bean performs all the actions i.e. fetching data, storing it and displaying the same using System.out.println
Now, the same data needs to be displayed on the browser. With Servlets, I'd use something like:

How can I access HttpServletResponse parameter in a JSP page, so that the same can be sent to the Bean in order to display the contents?
If there is any other way to do this, please let me know.
Thanks,
Saket
 
Bhushan Jawle
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For printing in JSP you can use the implicit variable "out" to do the printing which is of type javax.servlet.jsp.JspWriter
 
matt hooker
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Why not make use of the jsp:useBean functionality and access the data from the bean directly. Alternatively, create some sort of data object to hold the data you wish to display and then set it / get it from the session.
 
suresh guru
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the servlet use getServletConfig().getServletContext().getRequestDispatcher("jsp-page").forward(req,res)
by this u r passing the request & response present in this servlet to the jsp page
hope this helps
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic