Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

Servlets / How can we discard a request?

Thread view: 
Covington Bradshaw - 10 Mar 2007 02:36 GMT
Hi,
    In a servlet filter or servlet, how can we discard a request?
I.E. receive a given http request and simply decide to reject it
without answering the client with any response.

Thanks
Daniel Pitts - 10 Mar 2007 03:18 GMT
> Hi,
>         In a servlet filter or servlet, how can we discard a request?
> I.E. receive a given http request and simply decide to reject it
> without answering the client with any response.
>
> Thanks

Well, at the worst, you should return a 404 response. Its only polite.
If you don't want any response, why have a servlet at all?
Luc The Perverse - 10 Mar 2007 04:21 GMT
>> Hi,
>>         In a servlet filter or servlet, how can we discard a request?
[quoted text clipped - 5 lines]
> Well, at the worst, you should return a 404 response. Its only polite.
> If you don't want any response, why have a servlet at all?

Well you could set it up in firewall rules - if you had a security concern

--
LTP

:)
Chris Uppal - 10 Mar 2007 16:36 GMT
> > Hi,
> >         In a servlet filter or servlet, how can we discard a request?
[quoted text clipped - 3 lines]
> Well, at the worst, you should return a 404 response. Its only polite.
> If you don't want any response, why have a servlet at all?

Or one of the other 4xx or 5xx responses.  I agree that it makes no sense not
to respond at all -- if there's a reason why the server doesn't want to service
this request then it should /say/ so.

And, anyway, if the server just drops the connection without sending a standard
HTTP response, then the client will almost certainly retry -- thus increasing
the load on your server...

   -- chris
Ian Wilson - 12 Mar 2007 10:55 GMT
>>        In a servlet filter or servlet, how can we discard a request?
>> I.E. receive a given http request and simply decide to reject it
>> without answering the client with any response.
>
> Well, at the worst, you should return a 404 response. Its only polite.
> If you don't want any response, why have a servlet at all?

I'd return whichever is the most appropriate of:

401 - unauthorised
402 - payment required
403 - forbidden
404 - not found
405 - method not allowed
406 - not acceptable (data type)
407 - proxy authentication required
408 - request time out
409 - conflict
410 - gone
411 - length required
412 - precondition failed
413 - request entity too large
414 - request too long
415 - unsupported media type
Chris Uppal - 12 Mar 2007 19:38 GMT
> I'd return whichever is the most appropriate of:
>
> 401 - unauthorised
[...]
> 415 - unsupported media type

Don't forget the 5xx seriese of response codes.

   -- chris
Mark Space - 10 Mar 2007 07:12 GMT
> Hi,
>     In a servlet filter or servlet, how can we discard a request?
> I.E. receive a given http request and simply decide to reject it
> without answering the client with any response.
>
> Thanks

Not sure, but can't you do this with filters?  Filters have to chain,
iirc.  Don't chain, the request gets discarded.
Mike Schilling - 10 Mar 2007 08:34 GMT
> Hi,
> In a servlet filter or servlet, how can we discard a request?
> I.E. receive a given http request and simply decide to reject it
> without answering the client with any response.

You don't have that much control.  The servlet container will send a
response; all the servlet can do is determine its contents.  By writing
nothing to the response's stream, you can make the body of the response
empty.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.