File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 14687

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: 14687

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: 1321

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: 39530
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?

Ping & DNS - updated with new look and Ping home screen widget
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:
subject: JSP to HTML on serverside
Similar Threads
java.lang.IllegalStateException: Cannot forward after response has been committed
what's the # btw include , pageContext.include and jsp:include
bean compilation problem
Unable to compile class for JSP
storing variable so it can be used by 2 servlets