Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP not getting rendered

 
Somnath Mallick
Ranch Hand
Posts: 482
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

I have written a code of JSP-Servlet. Here is the code:


The request comes in from the HomePage.jsp. The thing is when i run this code from Eclipse it runs fine. But when i run from a browser there is chart.png image is not rendered in the browser! All i get is a browser with a blank page!

Could you please tell me if what i have done is correct.

chart.jsp code:

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In all honesty, I'm finding that code and JSP really, really difficult to read and understand--it looks like a complete nightmare to maintain and debug, for several reasons. I'm not even sure where to start, so I'll skip that part.

My first guess would be that your image tag is essentially empty. The second guess would be that you're trying to serve an image that isn't even in the web application context using an image tag.
 
Somnath Mallick
Ranch Hand
Posts: 482
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My image tag is something like this
IMG SRC="E:\\Softwares\\chart.jpg" WIDTH="600" HEIGHT="400" BORDER="0" USEMAP="#chart"
Somehow the text are not turning up in the code tag or even the quote tag!
I have tried running it in both IE and Firefox and they both display nothing!
Also could you please mention some pointers to make the JSP a little bit more readable!
 
Praveen mourya Kumar
Greenhorn
Posts: 16
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Somnath Mallick wrote:My image tag is something like this
IMG SRC="E:\\Softwares\\chart.jpg" WIDTH="600" HEIGHT="400" BORDER="0" USEMAP="#chart"
Somehow the text are not turning up in the code tag or even the quote tag!
I have tried running it in both IE and Firefox and they both display nothing!
Also could you please mention some pointers to make the JSP a little bit more readable!


Hi Somnath,

Can you please try to keep all the images under Application Context Root. I mean to say, make one folder(say images) near your WEB-INF. And try to access all the images from there.
 
Somnath Mallick
Ranch Hand
Posts: 482
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to create the file in the application context root. But i am running into some problems. I have changed the image file to be created to something like..

I want the image to be created in the images folder under WebContent folder (WebContent/images/chart.jpg). But the file is not being generated there and hence is not being rendered in browser.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That will try to create the image in directory under the root directory of a Unix system.

If you're trying to create the image in the web application's directory you'll need to get the real path.

IMO, this is a bad idea: dynamically-created images shouldn't be created in the web app context, as they might be removed during a redeploy, etc. Create them in, and serve them from, a directory that's guaranteed to exist, and guaranteed to not be destroyed. Images outside of the application context can be served via a servlet (or whatever back end technology you're using).
 
Somnath Mallick
Ranch Hand
Posts: 482
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's the problem... When I try to use a fixed path on my local system, it is working through eclipse, but not when i directly run the servlet through browser.
All i get is a blank page! I have attached a screen shot of my eclipse and mozilla. Please see!

The fixed path used is:

and i am rendering it like:
SRC="E:\\Softwares\\chart.jpg" WIDTH="1000" HEIGHT="600" BORDER="0" USEMAP="#chart"

within the Image tag!
Broswer.JPG
Browser Window.
[Thumbnail for Broswer.JPG]
 
Somnath Mallick
Ranch Hand
Posts: 482
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And this is the output i get from Eclipse:
Eclipse.JPG
In Eclipse.
[Thumbnail for Eclipse.JPG]
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to serve images outside the application context with a servlet (or whatever back-end technology you're using).
 
Somnath Mallick
Ranch Hand
Posts: 482
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no back-end application as such. This code just reads an excel sheet from a particular file path and a properties file and generates a graph. That's all.
Could you please kindly show me an example?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Somnath Mallick wrote:There is no back-end application as such.

I disagree, since you posted servlet code.

Images outside the application context should be served with a servlet--if you search the web for "image servlet" or something similar you'll find many, many examples.
 
amrish sharma
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think it may be a plugin issue
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
amrish sharma wrote:i think it may be a plugin issue

I already explained what the problem was. It has nothing to do with plugins.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic