How do I pass the part of the url that matched url-pattern to JSP?

Hello,
I have a web app called ptest.war deployed in JBoss. In my web.xml I have:
<servlet-mapping>
<servlet-name>GetImage</servlet-name>
<url-pattern>/images/*</url-pattern>
</servlet-mapping>
and:
<servlet>
<servlet-name>GetImage</servlet-name>
<jsp-file>DoImageRequest.jsp</jsp-file>
<load-on-startup>1</load-on-startup>
</servlet>
In DoImageRequest.jsp, I want to know what was requested by the user (so I can set some response headers and then re-direct to the image they requested), so if I go to:
http://localhost/ptest/images/i1.jpg
I want to have "/images/i1.jpg" available to me in the JSP, so that I can do a jsp:forward to the requested image, but none of the getters on the request object give me that string.
request.getServletPath() returns "/images" and request.getPathInfo() returns "/i5.jpg".
So do I need to construct what the user asked for by concatenating these two values?
The reason I was testing this was because I wanted to set no-cache in the response to the request for the image. Is there an easier way of doing that without having to direct the request to a jsp so that the jsp can set the response headers, which seems a little long-winded to me?
Many Thanks,
Paul Smith

I want to have "/images/i1.jpg" available to me in the JSP, so that I can do a jsp:forward to the requested image, but none of the getters on the request >object give me that string.Even if you manage to construct that, such a request path would be intercepted by your jsp because it maps to /images/*.
You would end up with infinite recursion.
To circumvent that, you can change the folder that stores the image - call it something like img and then you just need append the request.getPathInfo().
getServletContext.getRequestDispatcher("/img"+req.getPathInfo()).forward(req,res);
The reason I was testing this was because I wanted to set no-cache in the response to the request for the image. Is there an easier way of doing that >without having to direct the request to a jsp so that the jsp can set the response headers, which seems a little long-winded to me?You could have a filter intercept all requests for *.img, add the response headers and pass the request along to the actual resource. That would be easier and more intuitive. If your web app has a good fronting like an apache web server, I think you can cache your images on the web server and set a property that would instruct the web server to set a no-cache header in response when it serves the image.
ram.
Edited by: Madathil_Prasad on Mar 26, 2010 7:20 PM

Similar Messages

  • I've been trying to make an account with iTunes n everytime I get to the part of the credit card that's as far as I get because I dnt have one, how can I make an iTunes account without a credit card??

    I've been trying to make an account with iTunes n everytime I get to the part of the credit card that's as far as I get because I dnt have one, how can I make an iTunes account without a credit card??

    Where are you located?
    Just go and buy an iTunes gift card at any store in your country.
    Then follow all the steps you did, but when it asks you for the credit card number, there shoujld be a GIFT CARD option which will let you load your account witht eh funds form the gift card without providing a credit/debit card #.

  • How do I add web part in the event receiver after the site is provisioned in SP 2010?

    How do I add web part in the event receiver after the site is provisioned in SP 2010?

    You try the below steps:
    1. Use long operation to provision the site, so that it does not time out in process.
    2. After provisioning, you can add a page or add the web part directly to landing page of site.
    For each of the above steps you can find the sample code pieces.
    if you couldn't get that, let me know. I will share with you.
    Thanks, Ashish If my response has helped you, please mark as answer.

  • How can I pass a value to the command prompt?

    I was wondering how can I pass a value to the command prompt with Windows and Linux? I'm more interested in Linux's system than Windows though. Is there a way to return info from the command prompt?

    Here is a snippet from http://mindprod.com/jglossexec.html that explains how in detail.
    Runtime.getRuntime().exec("myprog.exe") will spawn an external process that runs in parallel with the Java execution. In Windows 95/98/ME/NT/2000/XP, you must use an explicit *.exe or *.com extension on the parameter. It is also best to fully qualify those names so that the system executable search path is irrelevant, and so you don't pick up some stray program off the path with the same name.
    To run a *.BAT, *.CMD, *.html *.BTM or URL you must invoke the command processor with these as a parameter. These extensions are not first class executables in Windows. They are input data for the command processor. You must also invoke the command processor when you want to use the < > | piping options, Here's how, presuming you are not interested in looking at the output:
    Runtime.getRuntime( ).exec ("command.com /E:1900 /C MyBat.bat" );
    Runtime.getRuntime( ).exec ("cmd.exe /E:1900 /C MyCmd.cmd" );
    Runtime.getRuntime( ).exec ("C:\\4DOS601\\4DOS.COM /E:1900 /C MyBtm.btm" );
    Runtime.getRuntime( ).exec ("D:\\4NT301\\4NT.EXE /E:1900 /C MyBtm.btm" );
    There are also overloaded forms of exec(),
    Runtime.getRuntime( ).exec ("command.com /E:1900 /C MyBat.bat", null);
    Runtime.getRuntime( ).exec ("command.com /E:1900 /C MyBat.bat", null, "C:\\SomeDirectory");
    The second argument can be a String [], and can be used to set environment variables. In the second case, "C:\\SomeDirectory" specifies a directory for the process to start in. If, for instance, your process saves files to disk, then this form allows you to specify which directory they will be saved in.
    Windows and NT will let you feed a URL string to the command processor and it will find a browser, launch the browser, and render the page, e.g.
    Runtime.getRuntime( ).exec ("command.com http://mindprod.com/projects.html" );
    Another lower level approach that does not require extension associations to be quite as well set up is:
    Runtime.getRuntime( ).exec ("rundll32 url.dll,FileProtocolHandler http://mindprod.com/projects.html" );
    Note that a URL is not the same thing as a file name. You can point your browser at a local file with something like this: file://localhost/E:/mindprod/jgloss.html or file:///E|/mindprod/jgloss.html.
    Composing just the right platform-specific command to launch browser and feed it a URL to display can be frustrating. You can use the BrowserLauncher package to do that for you.
    Note that
    rundll32.exe url.dll,FileProtocolHandler file:///E|/mindprod/jgloss.html
    won't work on the command line because | is reserved as the piping operator, though it will work as an exec parameter passed directly to the rundll32.exe executable.
    With explicit extensions and appropriately set up associations in Windows 95/98/ME/NT/2000/XP you can often bypass the command processor and invoke the file directly, even *.bat.
    Similarly, for Unix/Linux you must spawn the program that can process the script, e.g. bash. However, you can run scripts directly with exec if you do two things:
    Start the script with #!bash or whatever the interpreter's name is.
    Mark the script file itself with the executable attribute.
    Alternatively start the script interpreter, e.g.
    Runtime.getRuntime( ).exec (new String[]{"/bin/sh", "-c", "echo $SHELL"}";

  • How can I make a part of the body of my content full width of the screen with a fluid grid layout in CSS? (In dreamweaver program)

    How can I make a part of the body of my content full width of the screen with a fluid grid layout in CSS? (In dreamweaver program)
    and I know it is being over-ridden by
    .gridContainer {
      width: 88.5%;
      max-width: 1232px;
      padding-left: 0.75%;
      padding-right: 0.75%;
      margin: auto;
      clear: none;
      float: none;

    Abdelqader Alnobani wrote:
    How can I make a part of the body of my content full width of the screen with a fluid grid layout in CSS? (In dreamweaver program)
    and I know it is being over-ridden by
    .gridContainer {
      width: 88.5%;
      max-width: 1232px;
      padding-left: 0.75%;
      padding-right: 0.75%;
      margin: auto;
      clear: none;
      float: none;
    Logically a structure something like below should work BUT whether or not it will upset the FG I don't know as I wouldn't ever use it.
    <div class="gridContainer">
    Top Code Section Goes Here
    </div>
    <!-- close gridContainer -->
    <div id="fullWidth">
    Full width section goes here
    </div>
    <!-- close fullWidth -->
    <div class="gridContainer">
    Bottom Code Section Goes Here
    </div>
    <!-- close gridContainer -->

  • How can i pass a parameter to the query to filter the result of this lookup

    Hello,
    i'm developping a web application with JDeveloper 10.1.2 and JHeadStart.
    i realy need to know how can i filter the lookup (LOV) query result.
    in other word, when i click on the lookup, it show all the row that exist in may data base table.
    what i want is how can i pass a parameter to the query to filter the result of this lookup ?
    Thank you

    Hi,
    have a look if this helps
    http://oracle.com/technology/products/jdev/tips/fnimphius/restrictlovlist/restrictlov.html
    Frank

  • How can I copy a part of the picture and paste this piece on top of another part of the same picture? ta

    How can I copy a part of the picture and paste this piece on top of another part of the same picture? ta

    select the section you want to copy (marquee tool or lasso tool) and either go to edit copy or use control c create a new layer in layers (top menu bar) or Control shift N and paste using control V;  or edit > paste.

  • How can I pass environment variables to the child process?

    How can I pass environment variables to the child process? This is what I tried and it didn't work.
         static public void main (String[] args) throws Exception {
              ProcessBuilder b = new ProcessBuilder("java", "-cp", ".", "Child");
              Map<String, String> map = b.environment();
              map.put("custom.property", "my value");
                 b.redirectErrorStream(true);
              Process p = b.start();
              BufferedReader reader = new BufferedReader (new InputStreamReader(p.getInputStream()));
              String line = null;
              while (null != (line = reader.readLine())) {
                   System.out.println(line);
         public static void main(String[] args) {
              System.out.println("The value of custom.property is : " + System.getProperty("custom.property"));
         }and the result is:
    The value of custom.property is : null

    Complete test:
         static public void main (String[] args) throws Exception {
              ProcessBuilder b = new ProcessBuilder("java", "-Dcustom.property=my property value", "-cp", ".", "Child");
              Map<String, String> map = b.environment();
              map.put("custom.property", "my environment value");
                 b.redirectErrorStream(true);
              Process p = b.start();
              BufferedReader reader = new BufferedReader (new InputStreamReader(p.getInputStream()));
              String line = null;
              while (null != (line = reader.readLine())) {
                   System.out.println(line);
         public static void main(String[] args) {
              System.out.println("Property value of custom.property is : " + System.getProperty("custom.property"));
              System.out.println("Environment value of custom.property is : " + System.getenv("custom.property"));          
         }

  • In inches, how high is the part of the screen actually usable?

    In inches, how high is the part of the screen actually usable for text or images?... on the new iMac Apple computer models.
    In inches, how wide is the part of the screen actually usable for text or images?...
    Message was edited by: dsaklad@ zurich.csail.mit.edu

    You use [Pythagorean theorem|http://en.wikipedia.org/wiki/Pythagorean_theorem]
    !http://upload.wikimedia.org/math/1/4/5/1455314a78f39a594485adbaf74d63f9.png!
    to calculate how many pixels would go along the diagonal, C in the equation. You know A and B from the resolution numbers.
    Divide that pixel number (C from above) by the diagonal measurement in inches to get the +pixels per inch+ number (PPI).
    Divide the horizontal and vertical resolution numbers by the PPI number, to get the measurements in inches.

  • On the most upper left of the Title Bar (the part where the x box is on the right side) where the Firefox icon should be (on the upper left corner) I have a printer icon instead. Why did that happen and how do I change it? Thanks for any help.

    On the most upper left of the Title Bar (the part where the x box is on the right side) where the Firefox icon should be (on the upper left corner) I have a printer icon instead. Why did that happen and how do I change it? Thanks for any help.

    I don't actually have an answer for you, but ditto on changing things that aren't broken. Drives me crazy!!

  • If you install the program in Spanish, Can you switch to another language the part indicating the chapter's number?

    The company Aula24Horas has told to write a book in English.
    The part indicating the chapter's number is in Spanish.
    I would like to change it into English.

    Try changing the primary language on your computer to English.

  • I selected a clip in the Project window in iMovie 11, opened the Clip Trimmer for that clip, chose the part of the clip I wanted to keep with the yellow bars, and "trim to Selection" in the menu bar is light grey so I can't complete the edit. I'm using a

    I selected a clip in the Project window in iMovie 11, opened the Clip Trimmer for that clip, chose the part of the clip I wanted to keep with the yellow bars, and "trim to Selection" in the menu bar is light grey so I can't complete the edit.
    I'm using a MacbookPro so can't right click to highlight (as was suggested in this forum for the same problem) and can't seem to highlight that area. What do I do?

    When using the Clip Trimmer, you click DONE to indocate that you are finished.
    The Trim To Selection is a great tool and I use it all the time, but you use it in the main project timeline, not the clip trimmer. Just select the frames you want so that the yellow border is around them. Then right-click and select Trim to Selection.

  • Doestn recognize the part ahead the hyphen in an emailadress

    problem with the hyphen "-" the part ahead the hyphen of an emailadress is not recognized....do I make something wrong?
    For example  if i write the email:  [email protected]     the adobe acrobat only hyperlink the part [email protected]   in the created pdf.

    I open the shortcut Adobe Acrobat XI Pro from my desktop,
    then I choose the menu edit existing pdf
    afterwards I choose add text
    i create a box
    write for example : [email protected]
    I save the pdf
    i open my saved pdf
    push the mouse butten over the created email
    then the hyperlink only open my windows mail with the linked email: [email protected]
    the part "a-" is lost
    thanks for your answer

  • I'd like to be the part of the AppleSeed

    Hello,
    I've just got my iPhone 4S and I'm really interested to be the part of the AppleSeed community.
    I love to install and test the new apps, and report problems!
    If there is any was, please notify me!
    Thanks!

    Apple does not take applications for their seeding programs for testing unreleased software. If they're ever interested in recruiting you for any seed project, they'll contact you.
    Regards.

  • The hard drive for my MacBook Pro recently crashed.  I purchased and installed a new hard drive (i.e. Samsung SSD).  However, when I try to re-install the Mac's operating system, I come to the part of the installation instructions where you asked to selec

    The hard drive for my MacBook Pro recently crashed.  I purchased and installed a new hard drive (i.e. a Samsung SSD).  When I try to re-install the Mac operating system, I come to the part of the installation instructions where you are asked to choose a disk to install the software.  However, there is no disk listed in the selection screen.  Why is there no disk in the selection screen? 

    Welcome to Apple Support Communities
    You haven't formatted the SSD, so you can't install Mac OS X.
    First, close the OS X installer and open Disk Utility. Then, choose the SSD at the top of the sidebar, go to Erase tab, choose "Mac OS Extended (Journaled)" as "Format", and press Erase. Finally, close Disk Utility and reinstall OS X. See > http://pondini.org/OSX/DU1.html

Maybe you are looking for

  • HT204150 Sharing the same iTunes, Apple ID and iCloud accounts.

    Hi My wife and I share the same Itunes , Apple Id and Icloud accounts. How do we keep our contacts seperate, when we open up or back up on I cloud? As we both have I phones, I would like to keep all my work contacts seperate from hers. Also I don't w

  • Error in PDF & TXT output requests when using ixlib.cfg please help

    Hi Gurus, I am having a problem that The output for custom Arabic report in ghost viewer is coming garbage type characters so i added these below lines in adovars.env export IX_PRINTING=$FND_TOP/resource/ixlib.cfg export IX_RENDERING=$FND_TOP/resourc

  • Receiving multiple IDocs

    hi all; i have a scenario where i am receiving multiple IDocs and have to keep on receiving tthem till 15 mins. i implemented the scenario based on /people/pooja.pandey/blog/2005/07/27/idocs-multiple-types-collection-in-bpm but my IDoc messages seems

  • Subsequent credit

    hi, I need to clarify on the steps. 1) when receive CN from vendor due to price over charged. in miro, i choose transaction type subsequent credit. when come to line item, enter the PO and select the PO line where price affected. i need to change the

  • Mver, mseg table

    WHZ THE relationship between mver and mseg tables? i want to link up mara and mkpf tables.