JSP pages + getResource

Posted on 2003-03-23
Medium Priority
Last Modified: 2006-11-17
I am wanting to link my jsp system to a html file link depending on the value selected from the database which i am creating at www.csc.liv.ac.uk/~u0mpf/jspdatabase

Some of the links exist and not only do I want to check they exist, I also want to display a green dot if they do, and a red if they dont exist.  With the green dot being a link.  I think I should be using getResource() but I am not sure on ho to implement this.


Question by:michaelfollett
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 14

Accepted Solution

kennethxu earned 300 total points
ID: 8189993
getResource() is used to open a file in classpath. if you just want to check for existence of a file. you can just use:

java.io.File file = new java.io.File( "/file_system_absolute_path/page.html" );

if( file.exists() ) {
   // file exists
} else {
   // file doesn't exist

if your html files are under same webapp dire as you jsp is. you can use webapp relative path instead of using file system absolute path.

java.io.File file = new java.io.File( application.getRealPath("/path_relative_to_webapp_context/page.html") );
LVL 35

Expert Comment

ID: 10060252
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Points to kennethxu

Please leave any comments here within the next seven days.


EE Cleanup Volunteer

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
Learn how to use the free Acronis True Image app to easily transfer data between iPhones and Android phones.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

800 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