This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan 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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 60053
    
  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: 60053
    
  65

The context path is used when forming URLS, not file paths.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ContextPath Query
 
Similar Threads
JSP not getting rendered
Servlet with JFreeChart RequestDispatcher to view
How to display images on local disk(outside of WebContent of WAR) in jsp?
wsjspc ant task
how to insert an image