• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to parse a dynamic java generated string as a jsp page

 
Irma Nezirevic
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I have chosen to write a class which generates a large string filled with HTML code. Included in this string are a few taglibs references which are used to find the correct gif images.

The problem is that when I return this string to the jsp page the taglibs are not executed. This ofcourse fair enogh since the jsp page expects to recieve a string result that is to be shown on the html page and nothing else. BUT I also need for the taglibs and eventually something else jsp related, to be parsed as it normally would be in a jsp page.

Just to mentioned I have tried with out.println() and <&= %>.

Is this possible?? :-)

the pseudo code for the jsp page:

<%@ taglib uri="/WEB-INF/tld/engine.tld" prefix="wps" %>

...html/jsp code here...

//Here the class is called that generates the dynamic html string.
//How do I get the jsp engine to parse this string as a part of the jsp
//pages and not only handle it as an ordinary string.

<%=HtmlGenerator().generateHTML(DataBean)%>

...html/jsp code here...
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch Irma!

When you call Taglibs in JSP page, they will be executed by the container and will be treated a special entity then HTML.

When you call any method of pure-java-class-object, it does not executed by the container, hence Taglibs will not be treated as a special entity and hence you are facing problem.
 
Irma Nezirevic
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that sounds fun ;-) thanks for the answer
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to investigate the use of tag files if you are using a JSP 2.0 engine.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic