jQuery in Action, 3rd edition
The moose likes JSP and the fly likes JSP to HTML on serverside Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP to HTML on serverside" Watch "JSP to HTML on serverside" New topic

JSP to HTML on serverside

lubna kausar
Ranch Hand

Joined: May 06, 2006
Posts: 51
In my application I am haviing followings..
1>user creates request by filling up various forms (on JSP)
2>after user finishes all this final JSP having all the details is displayed.
3>the HTML generated from these JSP(including all the details of request) needs to be sent to authorised person via mail.

one suggestion i got is to generate the HTML code in java file and set it as the body of mail.

but i think it will be too complex to implement b'coz the JSP that generates this html is of 500+ lines!!!

I want to know is there n e way by which we can store the HTML generated from the JSP on serverside also in some directory?
by doing this what i will need to do is just to pass the HTML file in the mail body.
Please reply soon...
Its really urgent!
Thanks in advance!
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

I think that you could use RequestDispatcher's include() method to generate the same content from a servlet and send it to the user via email.

[My Blog]
All roads lead to JavaRanch
lubna kausar
Ranch Hand

Joined: May 06, 2006
Posts: 51
okay... Thank you very much
i am trying to search how to use this include() method to store the jsp into html format in some directory!
I would be very thank full if you can suggest in what directions i should search.
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

After some reflexion, I'm not sure that what I've spitted here would work. The include() will output the content of the JSP in the response's output buffer, so I'm not sure you can do something with it.
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1323

I don't know whether you guys are aware with delete option or not?

by using this.. you guys edit and delete as well,

[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Why does it have to be in HTML, and further, why does it have to be the same HTML as what the user sees? That doesn't make sense from a usability point of view. Why wouldn't a tabular text view -which can be generated easily on the server- suffice?
lubna kausar
Ranch Hand

Joined: May 06, 2006
Posts: 51
thanks i really did not know abuot deleting posts!!!
but now please suggest me some solution to my problem!!
lubna kausar
Ranch Hand

Joined: May 06, 2006
Posts: 51
hi ulf,
It needs to be the html b'coz its specified in the usecase doc. n in prototype as well.
now its must to implement it.
If there is a way to have the HTML on serverside please let me know.
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

First "b'coz" is not a word in the English language.
Please be careful to spell words out correctly.
to find out why this is important to us.
Thank you.

As to your question, it is possible to get the generated HTML using a post processing filter but it would probably be more hassle that it's worth.
Web pages in a browser are put together differently than HTML in an email.

Specifically, with browsers, the initial HTML document is returned first.
The browser reads that page an then issues a separate request for each of the linked resources needed to build the page (images, css sheets, linked javascript sheets, etc..)

With email, everything needed to render the page is sent in one bundle (multipart request).

This means that, not only would you have to capture the generated HTML, but that you would have to parse it to figure out what additional resources are needed, and then build a multipart document that contains all of these resources.

If this were my issue, I would look into either getting the specs changed to allow (as Ulf suggested) sending a plain text email message or, building a simplified HTML message that can be easily built up from a plain old Java class.
[ April 18, 2007: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link: http://aspose.com/file-tools
subject: JSP to HTML on serverside
It's not a secret anymore!