• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Moving through servlets with grace

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Author
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bill,
I would suggest that you look at filters to help solve this problem.
CHeers
Sam
 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic