[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: servlet forward: things happen twice
Also,
This line may not be causing your problem, but I
think this is wrong in Servlet B:
String idx = (String) request.getParameter("key");
should probably be:
String idx = (String) request.getParameter("index");
-MLA
http://play.ign.com/games/defender.html
--- george wang <george_wang@bellsouth.net> wrote:
>
> I had similar experience before. I dont remember
> exactly what happened.
> But I think it was caused by some kind of recursive
> call. I would check
> servlet mapping and debug step by step to see where
> and how. -George
>
> =====
> ----- Original Message -----
> From: "Yong Wang" <wymz@yahoo.com>
> To: <ajug-members@ajug.org>
> Sent: Tuesday, February 11, 2003 11:47 AM
> Subject: servlet forward: things happen twice
>
>
> > Hi, I wonder if anyone could spot the problem here
> bcz
> > I am sure it is something very simple that I
> > overlooked:
> >
> > I have three servlets, A, B and C, where A
> forwards to
> > B or C based on some flags in request parameter.
> But
> > when A forwards to B, somehow both servlet A and B
> get
> > called twice by only a single get request. The
> > environment is tomcat 4.1.
> >
> > Servlet A
> > =========
> > public void doPost(HttpServletRequest request,
> > HttpServletResponse response) throws
> ServletException
> > {
> > doPost(request, response);
> > }
> >
> > public void doGet(HttpServletRequest request,
> > HttpServletResponse response) throws
> ServletException
> > {
> >
> > String key = (String) request.getParameter("key");
> > String idx = (String)
> request.getParameter("index");
> >
> > try
> > {
> > if (key != null && idx != null) {
> > RequestDispatcher rd =
> > getServletContext().getRequestDispatcher("B");
> > rd.forward(request, response);
> > } else {
> > RequestDispatcher rd =
> > request.getRequestDispatcher("C");
> > rd.forward(request, response);
> > } catch (Exception e) {
> > ;
> > }
> >
> > Servlet B
> > =========
> >
> > public void doPost(HttpServletRequest request,
> > HttpServletResponse response) throws
> ServletException
> > {
> > doPost(request, response);
> > }
> >
> > public void doGet(HttpServletRequest request,
> > HttpServletResponse response) throws
> ServletException
> > {
> > String key = (String) request.getParameter("key");
> > String idx = (String) request.getParameter("key");
> >
> > // do some processing and output to response...
> > }
> >
> > Servlet C (actually a JSP)
> > ===========
> > code omitted.
> >
> > I would appreciate any insight. pls email me
> directly
> > if you want to see the entire source listing.
> Thanks!
> >
> > yong
> >
> > =====
> >
> > // My alternate email: yongwang@mindspring.com
> >
> >
> > __________________________________________________
> > Do you Yahoo!?
> > Yahoo! Shopping - Send Flowers for Valentine's Day
> > http://shopping.yahoo.com
> >
>
__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com