This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

html processing

 
Sharon whipple
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i was wondering , is there any other way to process the output html of servlet beside filters ?
I am trying to avoid changing the source servlets.
using :

will sent the servlet html output directly to the client ,
any ideas ?!?!?
[ August 10, 2003: Message edited by: sharon pl ]
 
Bob Kerfoot
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sharon,
You can use the HttpServletRequestWrapper and HttpServletResponseWrapper classes with RequestDispatcher.include(request,response).
Per the Javadocs for RequestDispatcher.include:
"The request and response parameters must be either the same objects as were passed to the calling servlet's service method or be subclasses of the ServletRequestWrapper or ServletResponseWrapper classes that wrap them. "
Let me know if you need more details.
Bob Kerfoot
bkerfoot@wideopenwest.com
 
Sharon whipple
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks bob
I will try to use HttpServletRequestWrapper
and see if its answering my problem .

 
Sharon whipple
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bob
how do i use HttpServletRequestWrapper to execute other servlet ?
i cannot find the correct way ,
10000 thanks ,
sharon
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
 
aney thomas
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Sharon whipple
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i see ,
so i use HttpServletRequestWrapper in the exact same way :
charArrayWriter.write(wrapper.toString().substring(0,wrapper.toString().indexOf("</body>")-1));
and the wrapper.toString() method will give me the HTML code .

thank you vary much !
i will try to run this code .
Sharon
 
Eelco den Heijer
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i was wondering , is there any other way to process the output html of servlet beside filters ?
I am trying to avoid changing the source servlets.

Actually, filters act as a decorator pattern; you can place them before or after the service method. You have to write the filter, and change the deployment descriptor (so you do have to alter the descriptor); you never have to change the actual servlet code.
Hope this helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic