Servlet image problem

Discussion in 'Java' started by Giox, Jan 29, 2007.

  1. Giox

    Giox Guest

    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
     
    Giox, Jan 29, 2007
    #1
    1. Advertising

  2. Giox

    Daniel Pitts Guest

    On Jan 28, 10:56 pm, "Giox" <> wrote:
    > 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.
     
    Daniel Pitts, Jan 29, 2007
    #2
    1. Advertising

  3. Giox

    Giox Guest

    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

    On 29 Gen, 08:52, "Daniel Pitts" <> wrote:
    > On Jan 28, 10:56 pm, "Giox" <> wrote:
    >
    >
    >
    > > 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
    > > GiovanniWell, 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, Jan 29, 2007
    #3
  4. Giox

    Lew Guest

    Please do not top-post.

    Giox wrote:
    > 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
     
    Lew, Jan 29, 2007
    #4
  5. Giox

    Giox Guest

    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

    On 29 Gen, 08:52, "Daniel Pitts" <> wrote:
    > On Jan 28, 10:56 pm, "Giox" <> wrote:
    >
    >
    >
    > > 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
    > > GiovanniWell, 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, Jan 30, 2007
    #5
  6. On Jan 30, 6:25 pm, "Giox" <> wrote:
    > 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.
     
    Andrew Thompson, Jan 30, 2007
    #6
  7. Giox

    Giox Guest

    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.


    On 30 Gen, 08:55, "Andrew Thompson" <> wrote:
    > On Jan 30, 6:25 pm, "Giox" <> wrote:
    >
    > > 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, Feb 1, 2007
    #7
  8. Giox

    Lew Guest

    Giox wrote:
    > 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.
    >
    >
    > On 30 Gen, 08:55, "Andrew Thompson" <> wrote:
    >> On Jan 30, 6:25 pm, "Giox" <> wrote:
    >>
    >>> 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
     
    Lew, Feb 1, 2007
    #8
  9. On Thu, 01 Feb 2007 05:40:13 -0800, Lew <> wrote:
    > Giox wrote:
    >> 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.
    >> On 30 Gen, 08:55, "Andrew Thompson" <> wrote:
    >>> On Jan 30, 6:25 pm, "Giox" <> wrote:
    >>>
    >>>> 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?


    Someone's been watching too much Jeapordy!

    --
    Randolf Richardson -
    The Lumber Cartel, local 42 (Canadian branch)
    http://www.lumbercartel.ca/
     
    Randolf Richardson, Feb 2, 2007
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy Fish
    Replies:
    4
    Views:
    2,432
    Andy Fish
    Dec 17, 2003
  2. Sean Clarke
    Replies:
    1
    Views:
    1,922
    Sudsy
    Jan 7, 2004
  3. circuit_breaker
    Replies:
    2
    Views:
    2,045
    Jack Jia
    Apr 4, 2004
  4. chamikara
    Replies:
    1
    Views:
    49,909
  5. DiscoStu
    Replies:
    0
    Views:
    514
    DiscoStu
    Jul 8, 2004
Loading...

Share This Page