velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tatu Vanhanen" <>
Subject RE: Velocity and HttpServletResponse's sendRedirect()
Date Wed, 02 Apr 2003 05:26:46 GMT
If you override the "handleRequest( HttpServletRequest request,
HttpServletResponse response, Context ctx )" instead of "handleRequest(
Context ctx )", you are allowed to return null and handle the request
completely in there, so no Exceptions thrown.

The meaning of the handleRequest methods are the same, expect that the
version with also request and response as parameters allowes you to handle
the request completely by returning null as a template.

I hope this is what you need.

- Tatu V.

-----Original Message-----
From: Twan Kogels []
Sent: 1. huhtikuuta 2003 15:38
Subject: Velocity and HttpServletResponse's sendRedirect()

Hi all,

I have a problem with Velocity and HttpServletResponse's sendRedirect()
For example: I've got a servlet which extends from VelocityServlet. This
servlet overrides the "handleRequest()" methode of VelocityServlet which is
defined as:
public Template handleRequest( Context ctx )

The following part of code will illustrate the problem:

public Template handleRequest( Context ctx ){
	Template t=null;
		t=new Command(); //this methode returns a Template object.
	return t;

When go==true it calls sendRedirect(), then t=null, this means that when
go==true, handleRequest() will return null. Returning null results in a
stacktrace, cause handleRequest() should return a Template.

I now make use of a dummy Template object:

		t=new DummyTemplate();

This dummy Template is a empty template, just to avoid returning null and
getting a stacktrace.

I'm wondering can this be solved in a better way?

Best regards,

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message