• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

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

 
Rancher
Posts: 4686
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Marshal
Posts: 67279
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what your question has to do with beans, so I may be missing something...
 
Pat Farrell
Rancher
Posts: 4686
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4686
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I'm not sure if I approve of this interruption. But this tiny ad checks out:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!