Solved

Tomcat Servlet - Find directory of webapp

Posted on 2010-09-22
4
572 Views
Last Modified: 2013-11-24
In a servlet, I'd like to be able to find the web-inf directory of the webapps directory for web app the servlet is in dynamically.

How can I do this?
0
Comment
Question by:modsiw
  • 2
4 Comments
 
LVL 3

Author Comment

by:modsiw
ID: 33736936
Aka, on a windows box default install, I'd like to find:

C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\MyApp\
0
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 250 total points
ID: 33737388
ServletContext.getRealPath("WEB-INF")

or

Servlet.getServletContext().getRealPath()

or

request.getRealPath(request.getServletPath())

0
 
LVL 92

Assisted Solution

by:objects
objects earned 250 total points
ID: 33739621
0
 
LVL 3

Author Closing Comment

by:modsiw
ID: 33873447
thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
allswap challenge 6 80
PDFBox - convert image to PDF, PDF resolution 3 118
Need to track down Infection in a Server 2008 domain user profile 7 48
use lov values 2 37
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now