This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to include servlets from tags?

 
Justin Chu
Ranch Hand
Posts: 209
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's what I'm trying to do
<ct:layout>
Component: <br>
<ct:layoutComponent/>
</ct:layout>
layout: loads a user preference string from database, comma separated, containing mappings to servlets. Eg. comp/news,comp/motd,comp/stocks
Create a instance variable Iterator with the above String tokens.
layoutComponent: use Iterator from parent, and tries to include the servlet.
PROBLEM: the components do not show up in the right place on the website!
ATTEMPTS:
from layoutComponent
// Illegal to flush within a custom tag.
pageContext().include(url);
// Not showing up right
pageContext.getRequestDispatcher(url).include(pageContext.getRequest(), pageContext.getResponse());
Thanks
CHu
[ April 19, 2002: Message edited by: Chu Tan ]
 
ersin eser
Ranch Hand
Posts: 1072
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am lost , I did not understand your _vague_ question.
 
Justin Chu
Ranch Hand
Posts: 209
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry.. let me reexplain it.. hopefuly its not _vague_ this time..
How to INCLUDE a servlet FROM a JSP tag?
I have tried requestdispatcher.include(request, response), and the servlet's output does not display on the correct position on the HTML page.
I've tried pageContext.include("servletmapping"); and I got an exception thrown. Something about illegal to flush from within a Custom Tag.
Chu
 
Justin Chu
Ranch Hand
Posts: 209
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my solution to include from within tags. It includes an ugly hack which I do not recommend. When running OptimizeIt on the application, the flushes seem to be one of the bottlenecks, not significant though. If anyone can come up with a more elegant solution, please post their code. Thanks.
In the JSP that is going to use the tag that includes another page:

Within the tag, do this

Flushing might not be necessary if your tag stands alone.
[ June 24, 2003: Message edited by: Chu Tan ]
 
Brusk Baran
Ranch Hand
Posts: 132
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
very nice cheat...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic