aspose file tools*
The moose likes Servlets and the fly likes How do I retrieve path information to  the.jsp files in a subdirectory of a web app? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How do I retrieve path information to  the.jsp files in a subdirectory of a web app?" Watch "How do I retrieve path information to  the.jsp files in a subdirectory of a web app?" New topic
Author

How do I retrieve path information to the.jsp files in a subdirectory of a web app?

Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

I'm getting tired of writing a bean for every view within my webapp. So I want to have a subdirectory (way under web/WEB-INF/fee/fie/foe/fum)
that I can just place JSP files in, and then have my servlet display the JSP as a view, in the usual model-controler-view world. (I'm using @bear's frontman framework)

I know I can ask the class loader for all the resources, and recursively chase though the tree. Is there an easier way?

Since its under web/WEB-INF/fee/fie/foe/fum, can I short circuit the scanning?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61657
    
  67

I'm not sure what your question has to do with beans, so I may be missing something...


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

It happens to be a bean, not very relevant to the question. The fundamental question is about how a servlet/bean can find a file within the jar/war that its running in.
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Here is some code that I've been playing with, trying to figure this out:



When I run it, I get output:



The good news is that the real path to the war/jar is " /Users/pfarrell/sandbox/wayserver/webapi/build/"
and the usual WAR stuff is in /web/ and all the interesting JSP stuff is in /web/WEB-INF/

The bad news is that I still have no idea how to get a handle to whatever is the lead, to the place where I really want:
/web/WEB-INF/fee/fie/foe/fum/*.jsp
 
Don't get me started about those stupid light bulbs.
 
subject: How do I retrieve path information to the.jsp files in a subdirectory of a web app?