Viewing 1 post (of 1 total)
  • Author
    Posts
  • #26771

    I have a situation where I’m generating graphics on the fly to be included with a PDF document (created with the tag library and JSP).

    Normally, I would think about writing the images back into the web application where I could reference them with a relative URL.

    This fails in one of two instances:

    1. Running from a WAR file
    2. getRealPath returns null because the entire path is not readable by the server user

    In order to get around this, I write the images to java.io.tmpdir, then use a fully qualified URL to a servlet that can provide the image. This works quite well as long as there is no NAT in place.

    If there is a NAT in place, then I run into the issue called hair pinning. This is where a packet leaves a private IP, goes out the NAT, then immediately turns around and comes back in via the public IP. Unless specifically configured, NAT devices block this traffic.

    To get around the hair pinning issue, I have started using the following URL in the JSP generating the PDF with the image:

    file:///path-to-java.io.tmpdir/image-name.jpg

    So the img tag in the JSP looks like:

    oops

    This surprisingly enough works.

    My question is, is this access supported? If so, is this intentional? If not, how long can I rely on this before it breaks?

Viewing 1 post (of 1 total)

The forum ‘General questions / FAQ’ is closed to new topics and replies.