0

I have a java webservice (jaxws /jersey) and want it to display an image on the firstpage when I visit the webservice using the browser.

My @GET Method which's sending the html-code for the first page is as follows:

@GET
@Produces(MediaType.TEXT_HTML)
public String getHTMLSite(){

    String message = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"+
            "<html xmlns=\"http://www.w3.org/1999/xhtml\" dir=\"ltr\" lang=\"de-DE\">" +
            "<div style=\"padding-left:20px; height:200px; width:800px; font-size:20px;\">" +
                "<p>" +
                    "<h1 style=\"color:#313e7d\">" +
                        "Hello World. This is a Webservice URL" +
                    "</h1>" +
                "</p>"+
                "<img src=\"/images/img_logo.gif\" height=\"51\" width=\"537\"/>"+
            "</div>"+
            "</html>";


    return  message;
}

Everything is working fine except the image

<img src=\"/images/img_logo.gif\" height=\"51\" width=\"537\"/>

has not been found.

I moved the image into the WebContent / images/ directory.

What am I doing wrong?

Pavel Bucek
  • 5,304
  • 27
  • 44
Chris
  • 566
  • 1
  • 8
  • 20

1 Answers1

1

Since you've got your servlet-mapping set to /* Jersey is going to intercept all those requests to static resources and not know what to do with them. You could:

Community
  • 1
  • 1
condit
  • 10,852
  • 2
  • 41
  • 60