Relative URL in JSP

Hi all,
I've developed and deployed a web application on Weblogic. It extracts some data and create zip file and JSP page displays relative link to download it. All of this was working fine.
Now I have to extract the data to a different drive on the server. e.g. Y:/ExtractorApp/data/. My weblogic server is on a different drive e.g. C:/.
How can I provide the <a href=" link to the new location relative to the application deployment directory?
I tried setting <context-param> in web.xml as
{code
<context-param>
     <param-name>output</param-name>
     <param-value>Y:/ExtractorApp/data</param-value>
</context-param>
And accessed it in my jsp as follows<a href="<%=application.getInitParameter(output")%">But it resolve to the actual directory in the file system and I am unable to download the file by clicking the hyper link. I can only do this by right clicking -> Save Target As... on IE7.
Can some one help me to generate the link so that clicking on it will prompt the user to save the file.
Thanks,
Navi.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    </a>

You can't do that. At best is going to refer to the client's Y drive, which isn't what you mean.
You can't serve a file which is outside of your application server's file system. You can write a servlet which processes requests by reading from the Y drive and copying the data to the response. Or you can configure the web server which is in front of your application server to serve those files.

Similar Messages

  • Problem with include and relative path in jsp

    Precompile jsp with wlappc in 9.2, I got the error "The include file was not found" when the jsp use <%@ include file="../includes/dataEntry/code_error.html" %>
              This code used to work with 8.1. I notice that someone has report the same problem with 9.0 and you have patch for it. Is it fix in 9.2 or do I require a patch as well?
              Thanks,
              Khuemy

    When you precompile, can you say "Keepgenerated=TRUE". It might help you track
              down the difference with the URL. You should only get a 404 error when the
              resource is not found at runtime, which is independant of when you compile. The
              difference should be in how the URL is compiled.
              Chris
              ali wrote:
              > I am using WLS 6.0 SP1, when I use relative path in <jsp:forward> in my JSPs
              > it forwards ok if I am using directly JSPs but if I am using pre-compiled
              > JSPs (and have proper servlet-mappings
              > in my web.xml), I get 404 error with the relative-path, if I change it to
              > absolute path with pre-compiled JSPs it forwards ok , then.
              > any ideas why this is so?
              > thanks,
              

  • How to make browser aware of new URL after JSP:forward

    When I use JSP:forward (or pageContext.forward() for that matter) to forward from a.jsp to b.jsp, the browser still seems to think he's at a.jsp. Assumably because the request for the new URL didn't originate with the browser. This causes problems when I try to use relative URL's in b.jsp (the forwarded URL) since the client kindly tries to resolve them for me using the wrong base URL.
    For example:
    I log in at <mysite>/Security/login.jsp.
    Here, I do some login magic and then forward to /Accounts/index.jsp.
    The state of the browser is now:
    a) the URL is <mysite>/Security/login.jsp
    b) the page displayed is <mysite>/Accounts/index.jsp
    Is there a better mechanism I can use to keep browser URL and displayed page synched up?
    BTW, in this simplified example I could use JavaScript history.go(-1) to let the browser do the forwarding itself. This won't work in my actual scenario because I actually forward to a page stored in the session several requests back.
    Any help would be very much appreciated!
    Andy

    Assumably because the request for the new URL didn't originate with >the browserThis is correct.
    One way for the browser to show the URL is by using a sendRedirect() after doing all the necessary processing. But you will loose all request attributes during a sendRedirect(). To overcome this, after you have done all processing and are ready to process the accounts jsp, you can put the required info in the session. The accounts jsp can get the info from the session instead of from the request, and then reset these in the session to prevent further use.

  • Resolve Relative URLs in Http response.

    I am using java.net package classes to make Http calls to get HTML, which I display in a page (using JSP). Problem is that there are relative paths in anchor, images etc and so links don't work and images don't display. I would like to know if there is any way to convert relative urls to absolute urls.
    Thanks
    rcr

    I have found that ColdFusion has a tag CFHTTP that converts relative url to absolute url (by giving arttribute resolveUrl="yes"). I wonder how they do it.
    http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-p58.htm

  • Can't view dashboard with relative url in BI 4 Launchpad

    I created a dashboard using BIWS connections and I am able to preview the dashboard when i have the full path of Web Service URL but when I use the relative url and publish to launchpad I get the "Cannot access external data......, Unable to load URL:/dswsbobje/Services/Session..." error message. Any ideas on how to solve this?
    Thanks

    Are you trying to preview the dashboard from dashboard designer tool ?  If yes, then you must have a full web service url, otherwise, it will not be able to resolve the server and port.
    But, if you use relative URL and export the same to BO repository, you will be able to view the same by logging into BI Launchpad. There it can resolve the server name and port from existing session.

  • How to set up use of relative URLs for a BSP application

    Dear all,
    I need to access a BSP application through our external portal.
    This is failing because generated URLs are absolute URLs (they mention physical server name, not known of course on the internet) where they should be relative URLs (they use external portal URL as prefix).
    How to set this up?
    I'm logged on http://myportal.com/irj/portal and want to call a BSP application. To build this page, my internet client (Internet Explorer) tries to get elements from the server. Looking at HTTP trace, I can see that my IE is trying to reach the physical server, not known on internet of course, then page loading fails.
    Ex absolute URL : http://myservername.domain.com/sap/bw/[...]/image1.gif
    This is the behavior I can see at the moment.
    Relative URL : http://myportal.com/sap/bw/[...]/image1.gif
    This is what I'd like to see.
    Many thanks in advance for your help.
    François

    Any idea ?

  • Sharepoint 2013 Wiki Page - Links in content rewritten to relative urls

    We have an issue where on all SharePoint 2013 wiki pages any URL to items within the site containing the wiki page are rewritten to be relative URLs. This causes a huge problem when we surface these pages and a snippet of their content through a search web
    part because the links fail being relative to the wiki page itself. To further illustrated with an example.
    A site collection root page http://www.sp2013.com/default.aspx contains a search results web part returning all wiki pages in the site collection. There is a custom display template that renders
    the linked title of the wiki page and the first 500 characters of formatted text (html) of the wiki page.
    A wiki page is created in a sub site (sub1) called wiki1 (http://www.sp2013.com/sub1/pages/wiki1.aspx) the text of the page contains:
    "Check out our new library: Document Library"
    Document Library is a hyperlink to (http://www.sp2013.com/sub1/Document%20Library/Forms/AllItems.aspx)
    Upon saving the wiki page the link is reformatted to be /Document%20Library/Forms/AllItems.aspx
    From the rollup web part at http://www.sp2013.com/default.aspx the relative url in the snippet text of the display template evaluates to
    http://www.sp2013.com/Document%20Library/Forms/AllItems.aspx which does not exist.
    I have attempted modifying the source of the wiki page as well as the link in the ribbon however upon save of the changes the link is always modified to be relative. Any assistance is appreciated as this is extremely frustrating. Thank you.

    Hi JonesEJ,
    According to your description, my understanding is that SharePoint converts a absolute URL to
     a relative URL when you save the wiki pages containing the URL.
    This is actually the preferred behavior in SharePoint and on the web in general. SharePoint saves all absolute URLs for the wiki content as relative. It only does this if the URL matches the URL for the web application for that current wiki
    site.
    There is no OOB way to change the relative URL back to the absolute URL. For your issue, you can try to use
    SPSite.MakeFullUrl() to convert it back.
    There is a similar post for your reference:
    http://sharepoint.stackexchange.com/questions/62887/absolute-urls-converted-to-relative-urls-when-saving-item
    Best Regards,
    Wendy
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Wendy Li
    TechNet Community Support

  • Relative URLs not working in JAR file once JAR is moved

    I've been loading images with the following:
    public static final ImageIcon anIcon = new ImageIcon("iconName.gif");
    This works fine when all the class files are in the same folder with the gifs. I then packaged the whole folder into a .jar file, moved the resulting .jar file to another directory, tried running it and none of the icons loaded. They are present in the .jar file, why doens't the relative URL still work? Is there simply another way to write the URL so that it knows to look in the .jar file?
    Thanks for help,
    Robert Douglass

    Is there simply another way to write the URL so that it knows to look in the .jar file?Once you put the class files along with your gif files in a jar, you have to access the gif file like this:
    import java.net.*;
    URL url=myClass.class.getResource("iconName.gif");
    ImageIcon anIcon = new ImageIcon(url);
    Where myClass is the name of your class file.
    V.V.

  • Problem with sendRedirect using relative URL in WebLogic 5.1 with SP7 & 8

    I patched to SP 7 (and also 8), and the request.sendRedirect() with relative
              URL failed. The browser simply displayed "404 - Page not found".
              This problem only happens in a cluster environment attached to a web server.
              SP6 or earlier does not have such problem.
              I noticed that the latest SP always formats the URL and returns it as a full
              absolute URL to the browser. The problem is it uses the Weblogic Server host
              URL where the request is processed (not the Web Server host URL) which is
              not visible to the internet.
              Is it possibly a bug in SP?
              

    I patched to SP 7 (and also 8), and the request.sendRedirect() with relative
              URL failed. The browser simply displayed "404 - Page not found".
              This problem only happens in a cluster environment attached to a web server.
              SP6 or earlier does not have such problem.
              I noticed that the latest SP always formats the URL and returns it as a full
              absolute URL to the browser. The problem is it uses the Weblogic Server host
              URL where the request is processed (not the Web Server host URL) which is
              not visible to the internet.
              Is it possibly a bug in SP?
              

  • Inspector-Hyperlink-An External Page = a Relative URL?

    I'm on iWeb '08 and have a question that I simply can't find an answer too despite searching many failed searches.
    I'm using iWeb to publish to a folder, so that I can later ftp the finished site.
    In my site, I want to add a hyperlink to an external URL, however the URL: box seems to only allow absolute url's to be entered after selecting Link To: An External Page.
    Is that right? Am I missing something?
    How do I create a hyperlink with a relative URL?
    Thanks in advance,
    JPS

    I don't understand what you mean by relative url?
    To create a hyperlink to an external page, click on Inspector in iWeb and then click on Hyperlink. When in Hyperlink click on 'link to an external page' and then type in the url that you want to link to and you can also have it open as a new page.
    Not sure what else you are trying to do?

  • How to use relative url

    I use xml file to save configuration and saved /WEB-INF/config.xml
    In my java class i can't use that file with relative url.
    document=builder.parse(new File("/WEB-INF/config.xml"));

    Try something like this:
    String thisPath = this.getClass().getResource("").getPath();
    document=builder.parse(new File(thisPath + "/WEB-INF/config.xml"));

  • Usage of relative url across site collections in sharepoint 2010

    Hi
    I have a webapplication with 2 sitecollections. In one sitecollection, created a link by going to navigation under sitesettings.
    Added relative url to map to 2nd site collection. Eg: /sites/site2/page1.aspx
    But by doing so, it is giving error. Help me out how to give relative url pointing to different site collection from another sitecolleciton.
    Thanks in advance
    Naina 

    Say, Site Collection 1 URL: http://sitecollection1.domain.com/
    Site Collection 2 URL : https://sitecollection2.domain.com/
    Now, on "Site Collection 1", In Site Actions-->Site Settings-->Navigation, when you use "relative URLs", it will always refer to the current Site Collection i.e Relative URL "/sites/site2" will always be "http://sitecollection1.domain.com/sites/site2".
    Anyways, what is the "requirement". What are you trying to solve by using "relative URL" for Site Collection 2 on Navigation of Site Collection 1. Reason for asking is, there might be different approach for your "requirement".
    Naveed.DG MCITP, MCTS -SharePoint 2010 Administrator "Vote As Helpful" If it helps!!

  • Relative URLs and Application Context

    How do you handle rendering relative URLs so that:
    1. Your application is independent of the application context it's deployed to
    2. You don't end up with lots of ugly code in your views
    3. The solution will work on any J2EE server
    I have several approaches, but I can't find any "best practices" discussions on this subject so I thought I'd start one.

    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
    "> Home</a>
    My main problem with that is that it's ugly as sin.                                                                                                                                                                                                                                                                                                                                                                       

  • Generating relative URLs in 12.1.3 menus

    Does anyone know if it is possible to get R12.1.3 to generate relative URL for all menu items?
    The new AJAX based menus are returning absolute URL for all menu item links.
    If this is the wrong forum please let me know
    thanks

    Hi,
    ERROR: I/O or zip error while attempting to read entry oracle/xdo/parser/schema/XSDIdConstraintTable$NodeTable.class in zip This error indicates one of the following:
    - Permission are not set correctly, so please verify the permissions -- See (Note: 339762.1)
    - The file is corrupted or missing, and you would need to find the file and copy it to the appropriate directory -- See (Note: 299723.1, 299964.1, 343639.1, 746167.1) for examples
    If none of the above helps, I would suggest you log a SR.
    Thanks,
    Hussein

  • Get Gateway name / url via JSP

    Anyone say what is the method to get the Gateway name / url via JSP?
    Thanks
    Fausto

    Alex, in the normal case you have reason the client host is the gateway host.
    A simple code:
    <%
    InetAddress inet = InetAddress.getByName( request.getRemoteHost() );
    String gateway = inet.getHostName();
    String portal="http://" + gateway + "/portal/dt";
    gateway="https://" + gateway + "/";
    String url=request.getParameter("url");
    if ( url != null) {
    response.sendRedirect(gateway + url);;
    }else{
    responde.sendRedirect(gateway + portal);
    %>
    I put a jsp in the web container, I contact the jsp trough an url
    http://www.mydomain/portal/desktop/redirect.jsp without the method get for the url variable, if I call the jsp directly without gateway from my client the gateway variable is my dns hostname and the jsp cannot redirect my in the portal login page
    If I take the localhost, it works fine but if a particular case when the gateway and the platform are the same host.
    There is not a HTTP enviroment variable to get the gateway name or a simple java method to ask the correct host?
    Thank you again
    Fausto
    http://www.mydomain/portal/desktop/redirect.jsp
    i

Maybe you are looking for