Re: Sending HTTP response codes

Denny Chambers <[email protected]> Mon, 26 Jan 2004 23:34:30 -0600
Newsgroups gmane.comp.java.enhydra.barracuda.general
Message-ID <[email protected]>
Thanks Jacob. I actually got it working earlier. I actually got it on 
the first try, this is what I did:

//This is inside a "public void handleControlEvent(ControlEventContext 
context) throws EventException, ServletException, IOException"

// Get the responce class
HttpServletResponse res = ((DefaultEventContext) context).getResponse();
// Need to set the auth type and the auth name
res.setHeader("WWW-Authenticate", "BASIC realm=\"Administration Access\"");
// Send the error
res.sendError(HttpServletResponse.SC_UNAUTHORIZED);
//Make sure Barracuda knows this is handled.
event.setHandled(true);

Not sure if I need the last call or not...but it works as is.

Denny

Jacob Kjome wrote:

>
> You should be able to send a normal servlet response and set the event 
> as handled.
>
> response.sendError(res.SC_UNAUTHORIZED);
>
> Jake
>
> At 01:43 PM 1/26/2004 -0600, you wrote:
>
>> Hi ALL,
>>
>> I need to be able to send HTTP 401 Unauthorized responses from 
>> Barracuda, when my ValidateEvent handles sees that the user is not 
>> logged in. Are there any canned Render Handlers, or Exceptions to 
>> handle sending back different HTTP codes? I know that the 
>> ClientSideRedirectException will allow you to send 307 redirect 
>> responses, but what about the other types of responses?
>>
>> Thanks,
>> Denny
>>
>>
>
> _______________________________________________
> Barracuda mailing list
> [email protected]
> http://barracudamvc.org/lists/listinfo/barracuda
>
>
smime.p7s (application/x-pkcs7-signature, 3.1 KB) - not displayed