Hades
Hades

Reputation: 3936

how to send parameters to jsp

So I'm using JFree chart and I'm trying to generate an image and display it in my jsp code. I would like to know how to accomplish this. I have tried multiple different ways but it doesn't work.

I saved the file and then when I try to access it. It is stored on the webserver and therefore I don't have the url to it?

Any help would be much appreciated.

I also tried to do something like this,

 <IMG SRC="chart.jsp"
         WIDTH="300" HEIGHT="300" BORDER="0" USEMAP="#chart">

which is basically jsp which generates an image. It works but how can pass parameters to it?

Upvotes: 0

Views: 1399

Answers (2)

Scary Wombat
Scary Wombat

Reputation: 44854

Instead of thinking of the img source as static file think of the url being a stream that will be returned from a servlet using a prticular URL

eg

<img src="/jfreeServer?param1=123"/>

Upvotes: 1

JB Nizet
JB Nizet

Reputation: 692161

You shouldn't use a JSP, but a servlet to generate an image. JSPs are view components, whose role is to generate HTML markup from a model prepared by a controller.

But anyway, you pass parameters to a JSP the same way as you do for any other URL:

<img src="chart.jsp?param1=value1&param2=value2" .../>

Upvotes: 1

Related Questions