1

Greeting,I want to render the whole html page in jsp and do some operation like replace the text according to code before run on server.Is it possible.Actually I am new in java Programming.In .net ,I render the html from xml file like this

<appSettings> <add key="CreateUser" value="~/App_Data/CreatingUserhtm.htm"/> </appSettings>

how can i render html page in jsp?

  • 1
    Please clarify. I don't understand what you're asking. A JSP is just like an HTML page, but with dynamically-generated parts. – JB Nizet Apr 16 '13 at 18:33
  • Just need a clarification, do you want to render your HTML in your JSP from an XML file (pre-existing) or are you passing data from a servlet (or something else) to your JSP? – Menelaos Apr 16 '13 at 18:36
  • I have a html page which I want to use to send in email.First i want to fetch the html source in String type and after that replace the some portion with current data – SarabjeetSingh Apr 16 '13 at 18:37

1 Answers1

1

This all depends on the amount of content that is "dynamic", and what your original question means.

JSP Reading XML content to Render

I would say you have the option to use XSL and do it all in the client that will also reduce the overhead on your server. You can use XSL to convert XML to HTML client side.

Otherwise you could also use XSL within JAVA and transform the XML. See: http://www.java2s.com/Code/Java/JSP/JSPXMLandXSLTtransform.htm

XML data sent from Servlet to JSP

If you want to set variables from a servlet and read them in a JSP (utilizing MVC pattern e.g.), you could use one of the following references:

Community
  • 1
  • 1
Menelaos
  • 23,508
  • 18
  • 90
  • 155
  • Just need a clarification, do you want to render your HTML in your JSP from an XML file (pre-existing) or are you passing data from a servlet (or something else) to your JSP? – Menelaos Apr 16 '13 at 18:37
  • Ok,I now understand how it can be possible thank's for your support – SarabjeetSingh Apr 16 '13 at 18:43
  • That's a huge topic, are you using some standard XML format? Do you want to render the whole XML? Do you want to render the data in the tags in a specific way? You need to also specify what each tag essentially means. So, you need a XML parser, and then to write code that goes through the XML elements, and outputs HTML. Another option non-java based is to use XSL to convert XML to HTML: http://www.htmlgoodies.com/beyond/xml/converting-xml-to-html-using-xsl.html – Menelaos Apr 16 '13 at 18:43
  • Ok, I updated the answer also to include XSL (via JAVA or browser). Have a look, it may be what you want! – Menelaos Apr 16 '13 at 18:49