How to obtain a URL from a path in a class' method?

Hey everyone!
Newbie here needing to convert the following method from a jsp page into a class for one of our applications.
I have a method in a class which takes a path (as a string). However, I can't seem to figure out how to have java output the corresponding URL in a jsp page.
For example, in the jsp file, I would provide something like:
"./../../../../../../temp/gfx/" as the path.
The "getRealPath()" method converts it nicely to a URL. However, I can't seem to figure out how to use this method within a class file. Is there a way to obtain the URL from a class' method? If so, how?
--- old code below ---
ServletContext application = getServletConfig().getServletContext();
String msg = "";//#Either the IMG tag or message to be returned.
File dir = new File(application.getRealPath(IMAGE_DIRECTORY));

Thanks for that hint!
Also, we're using Websphere... is there an easy way to take a partial url passed as a string and find the full path for it?
Example:
/images/today/
and have it automatically converted to:
F:/Inetpub/wwwroot/images/today/
automatically in java?
Or is this something where both a full system path and URL need to be passed?
Thanks!

Similar Messages

  • How do I keep URLs from printing after Events?

    Version 3.0.8 (1287) - How do I keep URLs from printing after Events?

    Open the Pages preferences > uncheck Automatic detect email and web addresses

  • How can obtain a row from an attribute

    Hi, i´m doing a smart project and i need only one row, how can obtain it?
    The row i want obtain it from an attribute.
    Thanks,

    Finally i do it with this method:
         public Vector getFile(MeIterator syncBos, int fromIndex, int count, String id) {
              // We want usually all items in the MEIterator because the SmartSync API already delivered
              // the correct part of items we want to display.
              // the fromIndex and count variable are only there in case we need a single entry.          
              Vector retVec = new Vector();
              int i = 0;
              if (syncBos != null) {
                   syncBos.reset();
                   // Fill table header with Field Names of Top Row
                   while (syncBos.hasNext()) {
                        /*                    SyncBo sb = (SyncBo) syncBos.next();
                                            if (i >= fromIndex) {
                                                 Vector rowData = new Vector();
                                                 for (int col = 0; col < getColumns(); col++) {
                                                      rowData.addElement(getHeaderFieldValue(sb, tableHeaderNames[col]));
                                                 retVec.addElement(rowData);
                        Row row = (Row) syncBos.next();
                        if (i >= fromIndex) {
                             Vector rowData = new Vector();
                             if ((getHeaderFieldValue(row, tableHeaderNames[1])).equals(id)) {
                                  for (int col = 0; col < getColumns(); col++) {
                                       rowData.addElement(getHeaderFieldValue(row, tableHeaderNames[col]));
                                  retVec.addElement(rowData);                              
                        i++;
                        // return when count has been reached, when count is greater 0.
                        // if count less 0 we get all records.
                        if (count > 0) {
                             if (i >= (fromIndex + count))
                                  return retVec;
              return retVec;
    Thanks,

  • How to get current URL from Internet Explorer ?

    Hi,
    I have design an add-on for IE and I'm
    trying to get URL from IE which is currently opened that is which is currently user sees. Is there any way to get it? I want to store that address in label and use it for something useful. Is it possible with C# ?
    I have did the following code to get current URL but it showing last opened URL instead of current URL which is user see
    using SHDocVw;
           SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();
                         string filename;
                         foreach (SHDocVw.InternetExplorer ie in shellWindows)
                             filename = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
                             if (filename.Equals("iexplore"))
                               label1.Text=ie.LocationURL;
                               label1.Text = ie.LocationName;
    and I have tried this one also 
    foreach (InternetExplorer ie innew ShellWindows())
       label1.Text = ie.LocationURL.ToString();
       label2.Text = ie.LocationName.ToString();
    Please give me any suggestion or code to solve this problem.
    Thanks.
    Priyanka

    You already got addon running in the active ie instance. You just need to catch the WindowStateChanged event in every instance so you can write down the last event with OLECMDIDF_WINDOWSTATE_USERVISIBLE somewhere. When you need the active IE instance, just
    pull from your save.
    Note an IE tab may crash and take your addon with it. It is better to start a broker process to store your global data.
    Visual C++ MVP

  • How to obtain public key from a .crt file

    Hi
    I am new to cryptography Please correct me if my understanding regarding the digital signature is correct and i need help to get the public key.
    I have a x.crt file which contains following fields
    1) x
    2)y
    3) Certificate
    this certificate contains following fields
    certificate version
    owner id
    name
    public key
    signature (which is obtained by signing from start of x.crt till public key with private key)
    now i need to verify whether the signature for that i need to get the public key & signature from this .crt file. Is it how i need to verify the certificate ?? please help me as I am a newbie in cryptography

    Hi all
    Thanks for the reply
    So to get the public key now i used the following code
    byte[] dataPub = new byte[256]; // size of the public key
    try {
                        byteArrayInputStream.read(dataPub);
                   } catch (IOException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
              BigInteger modulus = new BigInteger(dataPub);
         BigInteger exponent = new BigInteger("65537"); // specified in the document
         RSAPublicKeySpec rpks = new RSAPublicKeySpec(modulus, exponent);
         KeyFactory kf = null;
                   try {
                        kf = KeyFactory.getInstance("RSA");
                   } catch (NoSuchAlgorithmException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
         try {
                        pk = kf.generatePublic(rpks);
                        System.out.println("Pb Key----------------:"+pk.toString());
                   } catch (InvalidKeySpecException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
    When I convert the pk.toString I am getting a negative modulus value . Can the modulus value be negative ??
    Edited by: 800317 on Oct 8, 2010 5:51 AM

  • How to call a URL from forms ?

    Dear All,
    I would like to invoke / call a URL from forms. I know we can make a call Using Web.show_document. But this will execute in a browser.
    What i need to do is, i have to send a request to by calling an URL, that should not visible to any body.
    This is my requirement, please help if you know.
    Thanks
    Balaji

    hi,
    here is a quick example : (data from url returns as a clob. you need to write it at db. and call from forms.)
    FUNCTION Get_DataFromUrl(pUrl IN VARCHAR2,pProxy IN VARCHAR2,pData IN OUT CLOB) RETURN NUMBER IS
    vRcv UTL_HTTP.HTML_PIECES;
    vData CLOB;
    eNoDataReceived EXCEPTION;
    BEGIN
    UTL_HTTP.SET_DETAILED_EXCP_SUPPORT(TRUE);
    -- Get data pieces from Url
    vRcv := UTL_HTTP.REQUEST_PIECES(pUrl,Proxy => pProxy);
    IF vRcv.COUNT < 1 THEN
    RAISE eNoDataReceived;
    ELSE
    -- Append varchar2 table data into clob variable
    DBMS_LOB.CreateTemporary(vData,FALSE,DBMS_LOB.CALL);
    FOR i IN 1..vRcv.COUNT LOOP
    DBMS_LOB.WriteAppend(vData,LENGTH(vRcv(i)),vRcv(i));
    END LOOP;
    -- Copy local data into return variable
    DBMS_LOB.Copy(pData,vData,DBMS_LOB.GetLength(vData));
    DBMS_LOB.FreeTemporary(vData);
    END IF;
    RETURN SUCCESS;
    EXCEPTION
    WHEN eNoDataReceived THEN
    RETURN FAILURE;
    WHEN UTL_HTTP.INIT_FAILED THEN
    RETURN FAILURE;
    WHEN UTL_HTTP.Request_Failed THEN
    RETURN FAILURE;
    WHEN OTHERS THEN
    RETURN FAILURE;
    END Get_DataFromUrl;
    hope this helps.
    Engin.

  • Calling url from a form - err using ".value" method

    I'm trying to call url from a form, which seems to be the subject of many of these Posts.
    I have a form with a combo box/LOV and a button. The LOV will read a url into the combo box from a table of url's.
    I used the following code in the "OnClick" Java Script Event Handler section, which I pieced together from other posts in this and other forums. (i.e. I'm a pl/sql programmer trying to use Java Scripts for the first time).
    OnClick
    var X = FORM_DRWING.DEFAULT.A_DRILLDOWN_PATH.value;
    run_form(x);
    When I attempt to run this form from the "manage" window, I get a run time error "FORM_DRWING is undefined" upon clicking the button. FORM_DRWING "IS" the name of the form!
    The runform() function in the "before displying form" pl/sql code section is
    htp.p('<script language="JavaScript1.3">
    < !--
    function runForm(v_link)
    window.open(V_LINK);
    //-->
    </script>');
    This code was from yet another Post.
    Any help would be appreciated.
    Thanks, Larry
    null

    Hi Larry,
    the problem could be that you need to preface your form with 'document.'.
    i.e.
    var X = document.FORM_DRWING.DEFAULT.A_DRILLDOWN_PATH.value;
    Regards Michael

  • How to STOP OS X from automatically changing between language input methods

    I want to know if there is a way in OS X Leopard to stop the system from automatically changing the language input method. I use English and Japanese on my computer, but this would apply to anyone using more than one input method.
    For example, when I click on a Japanese-language file, the system automatically changes input to Kotoeri (the Japanese-language input method). When I then click on an English-language file it usually, but not always, changes back to English input. But I almost never want to TYPE in Japanese. I just need to be able to read Japanese and to cut and paste from Japanese language files. It is very annoying when I start typing in an English-language file and find the input method has been changed to kotoeri without me realizing it—everything comes out in meaningless Japanese. When I want to type in Japanese, I want to manually change to the Japanese input system. That is, I want English to always be the default input method even if I am manipulating Japanese-language files.
    So, I’m wondering if there’s a way to set the computer so that it never AUTOMATICALLY switches between the input methods. I want to be able to switch only manually. In the old days of System 7, 8, and 9, there was a third-party control panel you could get that would do this (I think it was called Stay There!) and I don't remember this being a problem in Tiger or earlier versions of OS X. Is anyone aware of any way to do this in Leopard?
    Thank you!
    Colin

    Well, I do have it set that way, and I can look up there to see where I am, but in the work I do time is critical and I move back and forth between the two languages frequently. It is really a pain and a waste of time to have to look and make a change that should be unnecessary. The problem is not so much that I don't know where I am. It's that I don't want to ever have to think I MIGHT be in anything but English input unless I specifically want to be. In other words, I need to be able to forget about this problem even being a possibility.
    Message was edited by: Colin Talcroft

  • How to execute Excel Marco from SAP using Office Integration Classes

    Is there a way to trigger Excel Macro from SAP? I tried using method CALL METHOD document->execute_macro
    of i_oi_document_proxy  but it does not work.
    Thanks
    Vivek

    Try this:
    If you are using OLE to populate the Excel Sheet then, then yes you can run a macro.
      CALL METHOD OF OBJ_EX_APP 'Run'
           EXPORTING #1 = MACROSTR.
    Adding a Field Exit
    To add a field exit first find the data element that is linked to the screen field- the screen number and program
    Run program RSMODPRF. You will need to create two function modules one FIELD_EXIT_MEPO_VENDOR and
    FIELD_EXIT_MEPO_VENDOR_A
    FIELD_EXIT_MEPO_VENDOR should have code simply of input = ouput.
    FIELD_EXIT_MEPO_VENDOR_A should have the code for whatever the functionality is required
    Go back to RSMODPRF and run the program without parameters. Use the push buttons to assign the screen, 'A' and program. Use the drop down to activate the field list.
    This should now work, but there is no way of debugging. For further information look at OSS 29377
    program zzdirlist.
    for AIX this method also works.
    DATA: BEGIN OF TABL OCCURS 0,
          TEXT(80) TYPE C,
          END OF TABL.
    DATA: COMMAND(256) TYPE C.
    COMMAND = 'ls'.
    CALL FUNCTION 'RFC_REMOTE_PIPE' DESTINATION 'SERVER_EXEC'
    EXPORTING COMMAND = COMMAND
    READ = 'X'
    TABLES PIPEDATA = TABL.
    LOOP AT TABL.
       WRITE:/ TABL-text.
    ENDLOOP.

  • How to obtain parent record from child record in relationship using API

    Hi,
    I have a record in the main table that is the child in a parent/child relationship to another main table record.  Using the Java API, how would I obtain the parent record in the relationship where I am starting with the child record?  In the API there seems to just be calls for getChildren, but not a getParent type call.
    Appreciate any immediate help that can be provided.
    Thanks,
    Eddie

    Hi Eddie,
    Please follow the below steps to retrieve only parents of a child Record.
    1. Create RetrieveRelationshipsCommand.
    2. Set the parameter RelationshipId.
    3. Set the parameter Anchor Record and Anchor Record Id. In this case the child record for which parents records to be retrieved.
    4. Set the parameter setGetChildren as false . This retrieves only the parent records for the specified child reocrd.
    5. Execute the RetrieveRelationshipsCommand.
    6. Retrieve member records from above step.
    Hope it helps
    Regards,
    Neeharika

  • How do I prevent Acrobat from changing paths to linked files when a PDF is saved locally?

    Hi,
    I'm creating a PDF for internal company use. Each page will include a button to view a video; the videos themselves will be hosted on an internal network drive.
    When I create the button in InDesign, I create an Open File action, browse to the video I want to link to, and it creates (what appears to be) an absolute path to the file. When I export to PDF, the path still appears to be absolute in the button properties, and if I open the PDF directly from its network location, the video button opens the video and works properly.
    If the PDF is sent as an attachment or downloaded from the network and saved locally, however, the video links no longer work. The filepath in the button properties still appears to be absolute, but now points to a local folder ("C:\Users\...")
    I need users to be able to download and save the PDF locally, but I don't want to embed a dozen videos, for obvious reasons. How can I ensure, then, that the filepaths to the videos are truly absolute and will consistently point to the network location no matter where/how the PDF is saved?

    It is relative, but I don't want it to be. The problem is that I don't see any way in either Acrobat or InDesign to specify that it must be absolute.
    It sounds like if I were to keep my working file on a local drive and export from there, it would automatically create an absolute link to the network path, but another designer is also working on the project and needs to be able to access the file. I could also copy the entire working folder to a local drive before exporting each time, or manually update the links in Acrobat from a local copy of the PDF after each export... but these both seem like ridiculous extra steps that shouldn't be necessary.
    Is it really possible that neither program allows the user to control whether a link is relative or absolute? Should I post this in the InDesign forums, though the issue seems to be in Acrobat?

  • How to call .aspx URL  from OSB

    Hi
    can any one please suggest how I need to call .aspx from OSB
    eg: http://<host>/ExternalServices/Customer/xyz/Posto.aspx
    Regards,
    Lavanya Sarma

    The service could have been a WSDL based web service or a normal XML/HTTP or SOAP/HTTP service without a WSDL definition.
    If its a WSDL based service you need a WSDL(along with any referenced XML schemas) and if its a XML/HTTP service then you need XML Schemas
    First of all you need to identify which one it is. To do that:
    1. Ask the team who has provided you the endpoint! If its a WSDL based service, ask them for the WSDL file along with referenced schemas. If its a XML/HTTP service ask them for XML schemas.
    2. If you are not able to contact them right away, Try accessing the URL in a browser:
    Open following URLs in a Browser:
    http://<host>/ExternalServices/Customer/xyz/Posto.aspx?wsdl
    http://<host>/ExternalServices/Customer/xyz/Posto.aspx
    Do you see any WSDL coming up in Browser? If yes then copy the content of the WSDL, also open the URLs of any imported schemas in the WSDL content in browser and copy their content as well. The idea is to have all the WSDLs and Schemas on your local machine,
    Once you get the WSDL files and XML schemas here is what you need to do:
    For WSDL based target servce
    1. Save the contents of any referenced schemas as XML Schema resources in OSB
    2. Save the content of WSDL as a WSDL resource in OSB
    3. Create a new business service, select WSDL based service types and select a port or binding from the WSDL resource you created in step 2
    4. Provide transport as HTTP and add http://<host>/ExternalServices/Customer/xyz/Posto.aspx as the endpoint
    5. Save this service and now you can call this business service from any Proxy Service in OSB
    If its a XML/HTTP service, then you can create business service with following types:
    1. XML HTTP with no specific XML schema - Choose ANY XML service type
    2. SOAP/HTTP with no specific XML schema - Choose ANY SOAP service type
    3. XML/HTTP with a specific request and response schema - Choose Message service type and select the request and (optionally) a response message type from an existing XML schema resource

  • How can I move file from one path to another   by java

    Hello
    I need to move the following file c:\abc\aa.txt
    to the follwing path c:\def
    How can i do it by java program?
    Regards

    Hi,
    Try the following code:
    boolean moveFile = new File("c:\\abc\\aa.txt").renameTo(new File("c:\\def",
    new File("c:\\abc\\aa.txt").getName()));
    Hope that helps.
    Savitha.
    OTN group@IDC

  • How to open an URL from Forms in blocking mode?

    Can anyone tell me if it is possible to open a website from within forms in blocking mode? The reason why I have to use blocking mode is that the user has to take some action in the website and has to end that session explicitly with a button on the website. After that, a file is written on the server that is needed for further action. Without that file the process can't go on.
    I use Forms (32-bits) versie 10.1.2.0.2.

    Thanks for your answer.
    Your suggestion is only possible with a timer-trigger (correct me if I'm wrong). And that's the point.... The time the user can act in the website is unlimited. So, how to set up a timer-trigger? Another work around is to make a process that works at some time and searches for the files on the server. But that's not what we want to do.
    Does anyone have another idea?

  • How can I stop URL from loading when I paste it into a page without selecting a text field first?

    I'm using a chat where I often copy links; if I forget to click the text field when copying an URL, it opens, forcing me to go back manually, which is really annoying. Can I disable URL autoopening somehow?

    It's possible that you are having a problem with some Firefox add-on that is hindering your Firefox's normal behavior. Have you tried disabling all add-ons (just to check), to see if Firefox goes back to normal?
    Whenever you have a problem with Firefox, whatever it is, you should make sure it's not caused by one (or more than one) of your installed add-ons, be it an extension, a theme or a plugin. To do that easily and cleanly, run Firefox in [http://support.mozilla.com/en-US/kb/Safe+Mode safe mode] (don't forget to select ''Disable all add-ons'' when you start safe mode). If the problem disappears, you know it's from an add-on. Disable them all in normal mode, and enable them one at a time until you find the source of the problem. See [http://support.mozilla.com/en-US/kb/Troubleshooting+extensions+and+themes this article] for information about troubleshooting extensions and themes and [https://support.mozilla.com/en-US/kb/Troubleshooting+plugins this one] for plugins.
    If you need support for one of your add-ons, you'll have to contact its author.
    If the problem does not disappear when all add-ons are disabled, please tell me, so we can work from there. Please have no fear of following my instructions to the line, as all can be easily undone.

Maybe you are looking for

  • WRT54GS V.5 AND WRT54GS V.6

    Which the difference between them? But the Hardware in v.6 is better? Sorry bad english.

  • EDW Architecture question

    Hi experts. I was searching for orientation in SAP help about EDW architecture details, but I didn’t find anything. We’re developing a new BW (2004s version) project and the challenge is to have one physical layer with EDW and another layer just for

  • Information required for BAPI

    Please provide some information or links concerned to these questions 1) What are BAPI's ? 2) What is the use of BAPI's in xMII?

  • OSX1.3.7 to 1.3.8 download problems

    I have tried downloading the software update, first from the apple logo, then from the apple website. It says 125 MB but downloads way past the number, up to 156 at one point. I can't get it so where do I go wrong?

  • Satellite L300 - Icons moved to the left

    All icons on function bar, on Satellite L300, have moved to the left . Tried to bring them back to normal position with mouse but failed. What can i do? Thank you