aspose file tools*
The moose likes Servlets and the fly likes JSP not getting rendered Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "JSP not getting rendered" Watch "JSP not getting rendered" New topic
Author

JSP not getting rendered

Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Mar 04, 2009
Posts: 477
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

Joined: Oct 14, 2008
Posts: 16
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.


SCJP 1.6..
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Mar 04, 2009
Posts: 477
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!



[Thumbnail for Broswer.JPG]

Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
And this is the output i get from Eclipse:



[Thumbnail for Eclipse.JPG]

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You need to serve images outside the application context with a servlet (or whatever back-end technology you're using).
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Sep 24, 2009
Posts: 20
i think it may be a plugin issue
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP not getting rendered
 
Similar Threads
Dollar Symbol at Vertical Bar in StackedBarChar in JFreeChart
Charts In JSP
Problem using JFreeChart
Barchart diagrams in jsp
Charts In JSP