tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Price <epr...@ptc.com>
Subject Re: servlets that forward to other servlets
Date Thu, 23 Jan 2003 18:18:38 GMT


Shapira, Yoav wrote:
> Hi,
> If it were a universal bad idea, it probably wouldn't be available as an
> options ;)  Although that may just be wishful thinking on my part.
> 
> It's not always a bad idea.  As usual, if you share your design and give
> some more concrete details, we may be able to help more. 

Good point -- here's the scenario:

My initial design was to have servlets perform all processing of user 
input, and each servlet redirects to a JSP to display the HTML to the 
user.  Unfortunately, I've found that sendRedirect() is not sufficient, 
since complex objects cannot easily be sent to the JSP as HTTP 
parameters.  Thus, I've decided to use 
getRequestDispatcher(some.jsp).forward() instead of sendRedirect(), 
since I can refer back to a complex object set in the servlet from the 
"receiving" JSP.

The only problem is that sometimes a servlet needs to forward to another 
servlet, for instance LoginServlet needs to forward to MainServlet. 
Most of the time, the user is already logged in and so does not need to 
use LoginServlet at all, but the first time they enter the application 
they will need to confront LoginServlet before confronting MainServlet. 
  So LoginServlet will need to forward to MainServlet, yada yada.

> If you're
> getting into a lot of request dispatchers, perhaps you should
> investigate a framework like struts.

I have no experience with struts, but everyone keeps talking about it. 
It seems worth learning, but I thought I'd try to write one complete 
basic webapp using only JSP + servlets first before going on to learn 
any frameworks, just for the sake of learning and so that I'd appreciate 
a proper framework more when someday I do use one.


Thanks,

Erik


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message