Servlet image problem

G

Giox

Hello everybody,
I would like to use a working servlet that generates png images as
source for a <img> tag.
When I access the servlet page generating the png image I can see the
correct image.
The address that I access is

https://localhost:8443/esempio_portale/graphPage

where /graphPage is servlet name mapped in web.xml file.
When trying to use such a servlet as src element of a img tag in a jsp
file, I have to use the following syntax:

<img src="https://localhost:8443/esempio_portale/graphPage"
alt="Impossibile visualizzare l'immagine" />

How can I avoid the full specification of the servlet path? I tried to
write

<img src="/graphPage" alt="Impossibile visualizzare l'immagine" />

with web.xml as follows:

<servlet>
<servlet-name>graphPage</servlet-name>
<servlet-class>com.biz.graph.graphPage</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>graphPage</servlet-name>
<url-pattern>/graphPage</url-pattern>
</servlet-mapping>

but it doesn't work. How can I obtain the desired result?
I'm using Tomcat 5.5
Giovanni
 
D

Daniel Pitts

Hello everybody,
I would like to use a working servlet that generates png images as
source for a <img> tag.
When I access the servlet page generating the png image I can see the
correct image.
The address that I access is

https://localhost:8443/esempio_portale/graphPage

where /graphPage is servlet name mapped in web.xml file.
When trying to use such a servlet as src element of a img tag in a jsp
file, I have to use the following syntax:

<img src="https://localhost:8443/esempio_portale/graphPage"
alt="Impossibile visualizzare l'immagine" />

How can I avoid the full specification of the servlet path? I tried to
write

<img src="/graphPage" alt="Impossibile visualizzare l'immagine" />

with web.xml as follows:

<servlet>
<servlet-name>graphPage</servlet-name>
<servlet-class>com.biz.graph.graphPage</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>graphPage</servlet-name>
<url-pattern>/graphPage</url-pattern>
</servlet-mapping>

but it doesn't work. How can I obtain the desired result?
I'm using Tomcat 5.5
Giovanni

Well, it looks like path in the URL is /esempio_portale/graphPage, so
you should use src="/esempio_portale/graphPage" /> instead of src="/
graphPage"

Hope this helps,
Daniel.
 
G

Giox

Thanks for your help, I will try the suggested solution .
I thought that the correct address to specify was that specified in
web.xml (the mapping).
Thanks Gio
 
L

Lew

Please do not top-post.
Thanks for your help, I will try the suggested solution .
I thought that the correct address to specify was that specified in
web.xml (the mapping).


It is. Try specifying a relative path:

src="graphPage"

- Lew
 
G

Giox

Well it works, thanks a lot, IO habe still some problem because I can
see the png image in IE but not in Firefox, but the problem is solved
 
G

Giox

You are right thanks a lot to Daniel it solved my problem.
For

src="graphPage"

it doesn't work, I don't know why, I will investigate.
Thanks for your link, I will check it asap.
 
L

Lew

Giox said:
You are right thanks a lot to Daniel it solved my problem.
For

src="graphPage"

it doesn't work, I don't know why, I will investigate.
Thanks for your link, I will check it asap.

A: Because it makes your post hard to read.
Q: Why is it bad?
A: Placing your response at the top of the message, ahead of the message quote
to which you are replying.
Q: What is top-posting?

- Lew
 
R

Randolf Richardson

A: Because it makes your post hard to read.
Q: Why is it bad?
A: Placing your response at the top of the message, ahead of the message
quote to which you are replying.
Q: What is top-posting?

Someone's been watching too much Jeapordy!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top