• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Response Header

 
Prabhakar Rao
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I want to know whether a requested resource is there or not on my server.
When a user send a request for a resource I need a mechanism on server to know whether it is there or not.

Thanks in Advance
Prabhakar
 
Lanka Prasad
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use HEAD instead of GET for a foreign URL. This will return header info with out body.

-Lanka
 
Prabhakar Rao
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you got what I asked for.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Prabhakar Rao:
Did you got what I asked for.


Probably not.
Why don't you try to explain a little more fully.
 
Prabhakar Rao
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure
Let assume that I am having a website.
I want to use Filters to customise the site.
In these Filters i want to know whether a resource requested for is available or not.
Suppose you type a bad url to my site I want to check for resource in the filter then pop appropriate message.

Hope you got the problem.
-Prabhakar
 
Kartik Patel
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't get you. Why you want to check in filters whether the resource is available or not.
you just follow the asusual flow and if resource is not available , direct it to specific page with message.

As I m not able to think the benefit of checking resource availability in filters.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Containers do this for you.
If you want to show your own page, just add your own custom 404 error page.
 
Prabhakar Rao
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks I know that error page mechanism was there.
But i need to know it programmatically.
 
Prabhakar Rao
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai
I want to know is there any mechanism for knowing whether a resource is there or not on the server.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly, patience is a virtue.

Secondly, think about for a minute. If the request is going to result in a 404, any filters would never be invoked. So how could you test for it?

The web.xml mechanisms are there for a reason.

If you want to test outside the bounds of a request to that resource, that's another story...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes and no.
You find out that something is not there when you try to access it and it fails. At that point the spec provides a way to handle this gracefully.

What you're describing sounds like it would genenerate two reads for every request. One to see if the file is there and then another to actually serve up the file/resource.

Also, all resources are not files on the system, requests can also be made for url-mappings to servlets, etc...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic