Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • Last Modified:

JSP pages + getResource

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.

Thanks

Michael
0
michaelfollett
Asked:
michaelfollett
1 Solution
 
kennethxuCommented:
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") );
0
 
girionisCommented:
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.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

girionis
EE Cleanup Volunteer
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now