wood burning stoves 2.0*
The moose likes Servlets and the fly likes How to know if it is a servlet or folder Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "How to know if it is a servlet or folder" Watch "How to know if it is a servlet or folder" New topic
Author

How to know if it is a servlet or folder

zan zang
Greenhorn

Joined: Jan 15, 2008
Posts: 6
Hi All,

I have an interesting question:

I have the following link:

http://www.somesite.com/news/topic

Now there are 2 possibilities:

1. There is a servlet called "topic"
2. "topic" is a folder name and which actually has one of the following file: index.jsp/index.html/index.htm

The question is:
How do I know the actual folder name?
In case 1, the folder name is "news"
In case 2, the folder name is "topic"

Now in the page there is an image with the following html:
<img src="hi.jpg">
How does browser know if it is
http://www.somesite.com/news/hi.jpg
or
http://www.somesite.com/news/topic/hi.jpg

Thanks.
Oscar Costa
Ranch Hand

Joined: Feb 05, 2009
Posts: 31

Hi,

The Servlet's name can be /news/topic too. It depends of servlet mapping in Deployment Descriptor...

"Do or do not... there is no try!" - Jedi Master Yoda
> SCJP 5 : SCWCD 5 : SCBCD 5 <
Rupali Bankar
Greenhorn

Joined: Mar 04, 2009
Posts: 3
RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
Do you think that website will be showing their original web Application structure to you ??

Never , these may be all false names , this is internally done with Directory Hosting or on to FrontController in the Application.


If you want something you never had do something which you had never done
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 928

are you talking from a developer's point of view or a hacker's point of view (i have answers for both but i need you to choose one before i proceed)


My Website: [Salvin.in] Cool your mind:[Salvin.in/painting] My Sally:[Salvin.in/sally]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42023
    
  64
You'll never know what's behind a URL. An URL like http://www.somesite.com/news/topic/hi.jpg may cause the image to be generated dynamically, without there ever being a file called "hi.jpg" anywhere, or a directory named "news/topic".


Ping & DNS - my free Android networking tools app
Bageshwar Pratap Narain
Greenhorn

Joined: Mar 04, 2009
Posts: 24
You can try ans check the response headers,
if they contain a last modified and created values,
you can make a guess if its a dynamic content or static


Bageshwar.Pratap.Narain
OCJP
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16092
    
  21

I haven't said it in a long time, but: A file server is not a web server.

EVERY URL request that comes into a web application server is parsed by the framework, using the web.xml file for guidance. If the URL patterns in web.xml indicate that the URL addresses a servlet, that request will be passed to the indicated servlet. Otherwise, the application container will use the part of the URL that comes after the context but before the query as a path to a resource inside the WAR. And just as a reminder, a WAR isn't necessarily a set of files and directories. In its official form, it's a ZIP file containing a resource directory that can be - but doesn't have to be - exploded into a set of files and directories.

On the client side, there's no way to tell WHAT will be done to a URL inside the server. It may even end up rewritten. For example, in JSF, a "/admin/myPage.jsf" might end up pulling in an "/admin.xhtml" resource to actually build the response. Even a simple "/images/myPic.gif" could end up being rewritten to convert a JPEG resource located in a completely different directory tree into a returned GIF data stream.


Customer surveys are for companies who didn't pay proper attention to begin with.
Bageshwar Pratap Narain
Greenhorn

Joined: Mar 04, 2009
Posts: 24
if they contain a last modified and created values,


you can re-request for the resource and check if http 304 is returned,
which means content not modified.
zan zang
Greenhorn

Joined: Jan 15, 2008
Posts: 6
Hi, thanks for all the reply,

I think I will end up with just consider the absolute path of hi.jpg as
http://www.somesite.com/news/topic/hi.jpg

The reason is if the page html set the path of the imag as
src="hi.jpg"

That's mean resource "hi.jpg" (No matter it is a static file or dynamically generated) is available on
http://www.somesite.com/news/topic/hi.jpg

If not, I believe that a "X" will be displayed on the browser and I don't think the web developer will like that before they publish the site.
 
Consider Paul's rocket mass heater.
 
subject: How to know if it is a servlet or folder