Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

Servlet image problem

Thread view: 
Giox - 29 Jan 2007 06:56 GMT
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
Daniel Pitts - 29 Jan 2007 07:52 GMT
> Hello everybody,
> I would like to use a working servlet that generates png images as
[quoted text clipped - 31 lines]
> 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.
Giox - 29 Jan 2007 08:43 GMT
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

> > Hello everybody,
> > I would like to use a working servlet that generates png images as
[quoted text clipped - 36 lines]
> Hope this helps,
> Daniel.
Lew - 29 Jan 2007 15:15 GMT
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
Giox - 30 Jan 2007 07:25 GMT
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

> > Hello everybody,
> > I would like to use a working servlet that generates png images as
[quoted text clipped - 36 lines]
> Hope this helps,
> Daniel.
Andrew Thompson - 30 Jan 2007 07:55 GMT
> Well it works, thanks a lot,

Who are you thanking?  Please refrain from top-posting.

>...IO habe still some problem because I can
> see the png image in IE but not in Firefox, ..

Try validating the resulting HTML here.
<http://validator.w3.org/>

Andrew T.
Giox - 01 Feb 2007 08:40 GMT
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.

> > Well it works, thanks a lot,
>
[quoted text clipped - 7 lines]
>
> Andrew T.
Lew - 01 Feb 2007 13:40 GMT
> You are right thanks a lot to Daniel it solved my problem.
> For
[quoted text clipped - 6 lines]
>>> Well it works, thanks a lot,
>> Who are you thanking?  Please refrain from top-posting.

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
Randolf Richardson - 02 Feb 2007 06:52 GMT
>> You are right thanks a lot to Daniel it solved my problem.
>> For
[quoted text clipped - 10 lines]
> quote to which you are replying.
> Q: What is top-posting?

    Someone's been watching too much Jeapordy!

Signature

Randolf Richardson - kingpin+nntp@lumbercartel.ca
The Lumber Cartel, local 42 (Canadian branch)
http://www.lumbercartel.ca/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.