• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP not getting rendered

 
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Greenhorn
Posts: 16
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
[Thumbnail for Broswer.JPG]
Browser Window.
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And this is the output i get from Eclipse:
Eclipse.JPG
[Thumbnail for Eclipse.JPG]
In Eclipse.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i think it may be a plugin issue
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
When you have exhausted all possibilities, remember this: you haven't - Edison. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic