Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP: Is it possible to use custom tags in a servlet?

 
Daniela Meyer
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there
I am trying to use a custom tag in a servlet:

The code above is simply ignored. Does anyone have any clues on this?
Thanks!
Daniela
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using them that way, no it's not possible unless you port the output to a file named .jsp and forward the request to the generated page.
Remember, Tags and the like on a JSP are Parsed into a java file and compiled. The container then executes the Java class file. Using the PrintWriter off the response sends the text unchanged to the browser (I know, filters and the like can modify the response but, we won't discuss that right now.)
You need to ask yourself what do you need from that Tag class? Once you determeine that, factor it out into a Poor Old Java Object and have the servlet and Tag use it.
 
Daniela Meyer
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much, Carl!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic