• 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

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
that sounds fun ;-) thanks for the answer
 
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
You might want to investigate the use of tag files if you are using a JSP 2.0 engine.
 
Cob is sand, clay and sometimes straw. This tiny ad is made of cob:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic