Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

forwarding data to printer friendly page  RSS feed

 
Joe Gliniecki
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using a front controller to do a database lookup and return an ArrayList of beans representing the rows in a table. I would like to have a link to a printer friendly page, but would rather not do another database query.

The only solution I can think of would be to use jsp:forward. But then I would somehow need some logic that does the forward only if the link is clicked.

Is there a common solution to this where the data from the previous request can be reused for the printer friendly page?

Thanks,
Joe
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Joe Gliniecki:
The only solution I can think of would be to use jsp:forward. But then I would somehow need some logic that does the forward only if the link is clicked.

You cannot use a forward. A forward is a server-side mechanism and it will occur on the server long before the page is sent to the user, let alone waiting for a click on an element.

The most common solution would be to obtain the database data again. That's what databases are for.

If for some reason you want to avoid going back for the data, you could cache the data in the session for later retrieval by a request after the click.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!