wood burning stoves 2.0*
The moose likes Servlets and the fly likes Moving through servlets with grace Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Moving through servlets with grace" Watch "Moving through servlets with grace" New topic
Author

Moving through servlets with grace

William Wild
Greenhorn

Joined: Dec 10, 2002
Posts: 23
Hi all,
What I am trying to do is handle two different form of responce. One is static xml files with their relevent xslt sheet which is handled by the DispatchServlet, the other is dynamically create xml data and then attach the relevent xslt sheet dependant on the data gathered. This is done in a separte servlet QueryServlet. However, I would like all responces to client requests to be given by DispatchServlet so I can handle all errors gracefully from the same point all the time.
I have just been through the code for the CocoonServlet to try to get a bit of inspuration for my own web servlet (As sugested by Bill in reply to my last post). But, apart from finding an astonishing lack of commenting (My professor would have them shot!), I could not see anything here to help.
Now I know there are two options. But I am a little unsure which would be the better.
1) sendRedirect(). But will this then be able to return the subsequent data grenerated in QueryServlet? (Remembering that I want to send the responce form DispatchServlet)
2) forward(). But in all the examples I have seen, this is the last thing to be done and I'm unclear where the path can or will end.
Any help , comments , critisism or direction pointing to manuals would be greatfully received.
Cheers
Bill


--<p>Bill<p>"Make it idiot proof,<br /> and someone will make a better idiot" -- ANON
Sam Dalton
Author
Ranch Hand

Joined: Jul 26, 2001
Posts: 170
Bill,
I would suggest that you look at filters to help solve this problem.
CHeers
Sam


<a href="http://www.samjdalton.com" target="_blank" rel="nofollow">Sam Dalton</a>,<br />Co-author of [http://www.amazon.com/exec/obidos/tg/detail/-/1590592255/qid=1068633302//ref=sr_8_xs_ap_i0_xgl14/104-4904002-9274339?v=glance&s=books&n=507846]Professional JSP 2.0[/URL] (October 2003)<br />Co-author of <a href="http://www.amazon.com/exec/obidos/ASIN/1861007701/ref=ase_electricporkchop" target="_blank" rel="nofollow">Professional SCWCD Certification</a><br />Co-author of <a href="http://www.amazon.com/exec/obidos/ASIN/186100561X/ref=ase_electricporkchop" target="_blank" rel="nofollow">Professional Java Servlets 2.3</a>
David Brafford
Ranch Hand

Joined: Feb 11, 2001
Posts: 91
Take a look at the Sun Core J2EE Patterns and
the Front Controller Pattern.
http://java.sun.com/blueprints/corej2eepatterns/Patterns/FrontController.html
Other patterns that you may find useful:
- Command ( each of your different request
types may be handled via creation of a
Command object ). Common elements can
be handled in the Front Controller.
Dave Brafford
-----------------------------------------
Considering the Certified Java Programmer Exam?
Get JCertify!
http://www.enterprisedeveloper.com/jcertify
The best investment in your career you will make all year
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Moving through servlets with grace
 
Similar Threads
Using a servlet to dispatch pages and redirect to other servlets.
XML
XSLT as a JSP's murderer
Servlet "Please Wait" Page
doPost() question