This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes ContextPath Query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "ContextPath Query" Watch "ContextPath Query" New topic
Author

ContextPath Query

Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Hi Everyone,

I am trying to display an image in a JSP using JFreeChart.
I have this code in the a scriptlet tag:

But when run the jsp on the server i get the following error:

Is the above code correct?
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Somnath Mallick wrote:

I think, the exception explain it all. Please make sure that you have "WebContent\images\chart.png " directory in your web app folder.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
\WebContent\images\chart.png exists. But still i get this error!
sathish Tl
Greenhorn

Joined: Sep 02, 2008
Posts: 7
Check request.getContextPath() contians any "%20" instead of space


Sathish TL
SCJP 5,SCWCD 5
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

I think, you won't require context path because you are referencing file from the server jsp, so simple relative path will work, like try
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

"satish TL", please check your private messages for an important administrative matter. Again.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

The context path is used when forming URLS, not file paths.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: ContextPath Query
 
Similar Threads
Servlet with JFreeChart RequestDispatcher to view
wsjspc ant task
how to insert an image
JSP not getting rendered
How to display images on local disk(outside of WebContent of WAR) in jsp?