• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting Page Source In The Servlet

 
Ranch Hand
Posts: 240
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All;

Anyone know of an easy way to get the page source (as in HTML) from a page that posts to a servlet?

The reason I'm asking is I would like to create HTML table in JSTL that could be used in another part of my application. If the servlet could some how get this generated HTML I would be in business.

Do I have to actually locate the file on the server and parse it? What if the html page is generated with a JSP (as in this case)?

Thanks,

Luke
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's like pulling yourself inside out.

If you want to reuse the JSP fragment that builds the table, a much more conventional -- and considerably less hair-pulling -- means of doing that is with a custom tag or an include file.
[ June 14, 2005: Message edited by: Bear Bibeault ]
 
Luke Shannon
Ranch Hand
Posts: 240
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the quick response.

Can you kindly expand a little bit on how I could use an included file to get JSP output in the servlet?

Thanks,

Luke
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My point was that you don't want to save the JSP output and try to reuse the output.

If you want the table to be the same in both places, use the same JSP fragment to generate it. By placing the fragment in an include file (or within a custom tag) you don't need to copy and paste any code, and can use it from multiple locations.

Why do you want to save the output for later display rather than just generating it on the fly? That's a real hinky thing to try to be doing.
 
Luke Shannon
Ranch Hand
Posts: 240
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What I am after is this.

The client uploads photos that get written into a table in the JSP (a gallery). As they upload they can check how it looks, changing the photos as they wish.

The photo names and locations are stored in a DB on the server.

That same table is written as part of a report to a file on the server by a class in the system. It looks up the locations of the files from the DB and generates the HTML to create the photo gallery.

Right now I'm building the table in JSP so the client can see it, than creating it again in a java class so it can be written into the report.

It would be nice if I could consolidate the 2, ideally creating all HTML in the JSP and none in Java.

I hope this gives a clearer picture.

Luke
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, so you want to use the JSP engine as a report formatter as well. I take it the report file is an HTML file?

Do you want to do the "report capture" as part of a client-initiated HTTP request? Or is this something that is initiated by another means?

You may want to look into Filters and the HttpServletResponseWrapper as a way of cpaturing the output.
 
Luke Shannon
Ranch Hand
Posts: 240
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The report file is an HTML.

The generation of the report is initiated by other means (not the submission of the form we are discussing).

Thanks,

Luke
 
reply
    Bookmark Topic Watch Topic
  • New Topic