ShowDocument,  valid URL

hi All,
I am very new to Java and would appreciate any help!
I have an applet running on our web server which our customers are using to search and look at files. Some files will have images (.pdf) that I would like for the customers to view in a new browser window.
I was able to show a .pdf file in a new browser by using the showDocument method, and hardcoding the url. url1= "http:/mywebserver.com/file123.pdf"
showDcoument(ur11)
My question is... what is the best way for me to validate and see if this pdf file exists ? so that I can show a button for the customer to view this document.
I am using the below method where xxx.pdf does not exist.. but it seems to always show the button even though xxx.pdf does not exist.
try {
url = new URL (http://mywebserver.com/xxx.pdf)
viewImageButton.setVisible(true);
catch (MalformedURLException e)
{viewImageButton.setVisible(false)}
Another thought I had was to use f.exists() to check if the file exists but that only works on local drives right ?
I would appeciate any help.
thank you !!

thanks for the suggestion marvin. the problem with that approach is that a database of all devices and their capabilities would need to be maintained and checked against. if we're just talking ipads, iphones and ipod touches, that's reasonable; but there's a huge and growing number of android devices out in the wild and they all have different capabilities...?
g

Similar Messages

  • Error Illegal access to the viewer. Please use a valid URL

    Hi, One question:
    Illegal access to the viewer. Please use a valid URL?
    Pls, any comment with this error.
    Regards
    LEJS

    Check the KBA 1892338 - Error: "illegal access to the viewer, please use a valid url" while viewing webi reports from BI Launchpad.This may be because of licence being expired.

  • Ume.logon.branding_image to a valid URL

    Hello Friends,
    I know that : "As of EP6 SP2, it is possible to change the branding image without having to modify code. Instead, you can set the user management property ume.logon.branding_image to a valid URL. For example:
    ume.logon.branding_image=/irj/newImage.gif.
    ume.logon.branding_image=http://www.company.com/Image.gif"
    On my system if i try to save the modifications the URL changed to
    ume.logon.branding_image=http\://www.company.....
    http\:// and not http://
    Could you please help me?
    Regards,
    Fth

    Hello,
    usually this occurs, or in cases of developing on unix/luinux/C/etc. it's required to set special commands like '/' or ':' out of their funktionality, the funktionality will be disabled with the presetting of the backshlash command sign '\'.
    So the stringset executing will be not interupted until the last sign is processed.
    Perhaps you should check your system environment at first.
    It seems, that the string processes a locally adress. In Windows environments such appearances occurs often, it also like a adress-string if you're typing in the browser a local file to show, here you must start like "file\://'
    I hope  it was helpfully and nearly correct.
    br.ct

  • Not a valid URL: Unexpected character found - Installation of SLD

    During the installation of SAP Solution Manager 4.0 Support Release 3 I am installing a local SLD (this is a test environment). When at the "Configure System Landscape Directory" phase of the installation I get the following error, java.net.MalformedURLException: Not a valid URL: Unexpected character found ['-' at position 18].
    Any help would be appreciated.
    ConfigMainExt state200
    TYPE=A<BR>STATE=<BR>INFO_SHORT=java.net.MalformedURLException: java.net.MalformedURLException: Not a valid URL: Unexpected character found ['-' at position 18]
         at com.tssap.dtr.client.lib.protocol.impl.URLScanner.next_token(URLScanner.java:587)
         at com.tssap.dtr.client.lib.protocol.URL.parse(URL.java:518)
         at com.tssap.dtr.client.lib.protocol.URL.<init>(URL.java:63)
         at com.sap.ctc.util.SLDConfig.importSldContent(SLDConfig.java:765)
         at com.sap.ctc.util.SLDConfig.performFunction(SLDConfig.java:154)
         at com.sap.ctc.util.ConfigServlet.doGet(ConfigServlet.java:74)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    //   => Importing Data : D:/usr/sap/A12/SYS/global/sld/model/CR_Content.zip URL=http://usbfg046dev-:50000 USER=J2EE_ADMIN ...
    ERROR: Not a valid URL: Unexpected character found ['-' at position 18]
    <BR>CONFIGURATION=

    During the installation of SAP Solution Manager 4.0 Support Release 3 I am installing a local SLD (this is a test environment). When at the "Configure System Landscape Directory" phase of the installation I get the following error, java.net.MalformedURLException: Not a valid URL: Unexpected character found ['-' at position 18].
    Any help would be appreciated.
    ConfigMainExt state200
    TYPE=A<BR>STATE=<BR>INFO_SHORT=java.net.MalformedURLException: java.net.MalformedURLException: Not a valid URL: Unexpected character found ['-' at position 18]
         at com.tssap.dtr.client.lib.protocol.impl.URLScanner.next_token(URLScanner.java:587)
         at com.tssap.dtr.client.lib.protocol.URL.parse(URL.java:518)
         at com.tssap.dtr.client.lib.protocol.URL.<init>(URL.java:63)
         at com.sap.ctc.util.SLDConfig.importSldContent(SLDConfig.java:765)
         at com.sap.ctc.util.SLDConfig.performFunction(SLDConfig.java:154)
         at com.sap.ctc.util.ConfigServlet.doGet(ConfigServlet.java:74)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    //   => Importing Data : D:/usr/sap/A12/SYS/global/sld/model/CR_Content.zip URL=http://usbfg046dev-:50000 USER=J2EE_ADMIN ...
    ERROR: Not a valid URL: Unexpected character found ['-' at position 18]
    <BR>CONFIGURATION=

  • Valid URL+regex

    hi, i want to implement a function that will check for validity of a URL, which user inputs in a textbox. i have to accomplish thru regular expressions (or any other methods are also acceptible).
    Suppose user inputs 'http://www.yahoo.com' it will say valid url
    'http://[email protected]' it should say incorrect
    'http://www.yahoo+.com it should say incorrect
    'http://www.yahoo.com@ it should say incorrect
    i have tried to implement this but it is not working correctly
    Pattern urlPattern = Pattern.compile("www\\.(.+[[a-z][0-9]&&[^~!@#$%^&*]])\\.(.+[a-z])");

    I usually look on google for this kind of thing: http://www.google.co.uk/search?num=100&hl=en&ie=UTF-8&safe=off&q=%22valid+url%22+%22regular+expression%22&meta=

  • Valid URL or Not

    Hi,
         I would like to know how to find a url is valid or not in scrollpane contentpath .
    Regrads,
    Kameshwaran A

    use the onLoadError event of the moviecliploader class to check the url before applying to your scroll pane's contentPath.

  • Single word search - Firefox tries first DNS looup even though the word does not look like a valid URL (browser.fixup... is disabled).

    When I enter a correct domain name in the location bar, it is resolved without any problems ("domain.com"). When I enter multiple words, not constituting a valid domain ("some domain"), it is automatically searched in my preferred search engine. If I enter a single word ("domain"), which is _not_ a valid domain, Firefox still attempts to first resolve it (which takes about 15 seconds).
    Is there a way to disable or fix this behavior?
    browser.fixup.alternate.enabled;false
    browser.safebrowsing.remoteLookups;false
    keyword.URL;http://www.google.com/search?ie=UTF-8&oe=UTF-8&q=

    It maybe better to use a (one letter) keyword bookmark if you want to do searches via the location bar. It is always possible that you want to access a local site without a TLD appended and in such cases you need to do a DNS look up.
    See http://kb.mozillazine.org/Using_keyword_searches

  • Firefox fails to load valid url from my desktop or from other links. after the failure it says try again and this always works 100% of the time. WHY??

    have many valid links on my desktop to locations I go to often. There is nothing wrong with the th links but about 20% of the time the connection will fail and I get a TRY Again message. It always connects 100% of the time on the second try. This occurs on 8 0r 10 different sites on a regular basis.

    Something you can try is resetting it all Settings > General > Reset > Reset all settings. Or go to Settings > Store &amp; sign out &amp; log back in. Another thing you can do is restore your ipod. This has happened to me but the only thing i did was that i created a new account but try doing the things above i just told you. :)

  • Firefox Home with Search panel does not load/appear. When I click the home icon a message appears that says Firefox is not a valid URL. Never did that before?

    Nothing different from the question. Firefox just does not load. When I place the mouse cursor over the home icon and do not click, a message panel seemingly powered by My Yahoo states "drag the AT&T globe to the left of the home icon in the toolbar and drop it there, then select "yes" from the pop up window and you are done." This was an action I did recently (not today) but don't see what this has to do with Firefox

    Do a malware check with some malware scanning programs.<br />
    You need to scan with all programs because each program detects different malware.<br />
    Make sure that you update each program to get the latest version of their databases before doing a scan.<br />
    <br />
    * http://www.malwarebytes.org/mbam.php - Malwarebytes' Anti-Malware
    * http://www.superantispyware.com/ - SuperAntispyware
    * http://www.microsoft.com/windows/products/winfamily/defender/default.mspx - Windows Defender: Home Page
    * http://www.safer-networking.org/en/index.html - Spybot Search & Destroy
    * http://www.lavasoft.com/products/ad_aware_free.php - Ad-Aware Free
    See also:
    * "Spyware on Windows": http://kb.mozillazine.org/Popups_not_blocked

  • How can I disable an Alert that indicates:"The URL is not valid and cannot be loaded".

    This Alert frequently pops up even after I've accessed a valid URL site on Firefox. Sometimes it takes 2 or 3 clicks to close the Alert window.

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode
    *https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes

  • How can I test if an URL is valid in Actionscript 3.0 ?

    Hy, everyone!
    I`m trying to make a function that tests to see if an URL is
    valid and return true if it is, false otherwise, so that I can use
    it in an 'if' statement.
    The way I try to do it is by using two event listeners for
    the 'contentLoaderInfo' proprety of a Loader: one for Event.OPEN(if
    this event is dispatched, then I know the URL is valid) and one for
    IOErrorEvent.IO_ERROR(if this event is dispatched, then I know the
    URL is not valid).
    But the problem is that by using the event handler functions,
    I leave the main URL tester function, and am unable to return a
    value from it. The way I thought of to get around this problem was
    to set a returnValue variable, to which to assign the return value
    of the two event handler functions and then just go 'return
    returnValue;'. But I don`t know how to return a value from a event
    handler function, and even if I did I still couldn`t do it that
    way, because it takes some time to dispatch those events and the
    'returnValue' variable would be undefined by the time I try to
    return it.
    I hope you understood what I tryed to explain above... Here`s
    some code to ilustrate this better(it`s not valid, it`s just so you
    understand my problem):
    private function testUrl(url:String):void {
    var returnValue:Boolean;
    var loader:Loader = new Loader();
    returnValue =
    loader.contentLoaderInfo.addEventListener(Event.OPEN, onGoodUrl);
    // This is a global variable to which I assign the value of
    'loader' so that I can close it from onGoodUrl
    _testLoader = loader;
    returnValue =
    loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,
    onBadUrl);
    loader.load(new URLRequest(url));
    // Even if I knew how to make an event handler that returns a
    value, I`d still have to wait for the loading to start, and I
    couldn`t return the value here:
    return returnValue;
    private function onGoodUrl(event:Event):Boolean {
    _testLoader.close();
    return true;
    private function onBadUrl(event:IOErrorEvent):Boolean {
    return false;
    You know any way to go around this problem? Or, for that
    matter, do you know any other way to test for a valid URL?
    Thank you for your time!

    You need to test httpStatus of the URLLoader. Streaming
    content undergoes a specific process when coming into Flash. The
    only issue with httpStatus is that it does not work for every
    browser....mostly Linux based systems and lesser programs on the
    evolutionary food chain. I have not experienced problems with IE or
    NS/FF on Vista at this point.
    1. Send Request
    2. Receive HTTP Status (HTTPStatusEvent.HTTP_STATUS)
    3a. Status Good - Begin Load (Event.OPEN)
    3b. Status Bad - 404 or Protected Filed
    (IOErrorEvent.IO_ERROR)
    4. Receive File - Downloading (ProgressEvent.PROGRESS)
    5. Download Complete (Event.COMPLETE)

  • Please enter a valid server URL when attempting to register on a custom sync server.

    This happens in the dialog when attempting to enter a custom sync server URL. Soon after typing http:// or https:// or even if you type any single character and wait a few seconds, the words "Please enter a vlid server URL" appear under the entry field next to a X in a red box.
    After entering a complete and valid URL the above text never goes away and the "next" button never gets enabled. Including after filling all the rest of the dialog. that error message remains and it is impossible to go forward.
    This happens on all of my desktop Firefox installations. I can't test it on a mobile device as it is not possible to create an account that way.
    I've tried it with and without a port number in the URL.

    Try to ask advice on IRC (irc.mozilla.org) in the #sync channel as mentioned at the bottom of the article.
    *http://docs.services.mozilla.com/howtos/run-sync.html

  • How to create a URL in R3 system?

    Hi experts,
    My requirements is that external application will send a XML message to R3 system via a URL.But I don't know how to create a valid URL in R3 system.Who can help me.many thanks.
    Kelvin

    Hi,
    Check the below FMs,
    HTTP2_GET                      HTTP Get
    HTTP2_GET_FILE                 HTTP Get File
    HTTP2_GET_FILES_255            HTTP Get Files
    If u have any middleware like XI or SAP BC it will be simple.
    Thanks and Regards,

  • What's wrong with my AppletContext.showDocument?

    ive been having a hard time figuring out my problem and i think its time to let this problem out to the world. im trying to call a certain html file to be shown on a certain frame of another html file, after a Java-made button is clicked.
    to clear things out, here's the code:
    <code>
    import java.applet.*;
    import java.net.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.AbstractButton;
    import javax.swing.JButton;
    import javax.swing.JPanel;
    import javax.swing.JFrame;
    import javax.swing.ImageIcon;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.KeyEvent;
    public class TestHomeButton extends Applet implements ActionListener {
         JButton homeButton;
         JPanel panel;     
         AppletContextAdapter fetchURL = new AppletContextAdapter();     
         public void init( ) {
              setLayout(new BorderLayout( ));
              setBackground(Color.white);
              homeButton = new JButton("Home");
              homeButton.setVerticalTextPosition(AbstractButton.CENTER);
         homeButton.setHorizontalTextPosition(AbstractButton.CENTER);
              homeButton.setToolTipText("History & Introduction");
              homeButton.setActionCommand("home");
              homeButton.addActionListener(this);
              add("Center", homeButton);
         public void start( ) {
              System.out.print("Applet starting.");
         public void stop( ) {
              System.out.print("Applet stopping.");
         public void destroy( ) {
              System.out.print("Destroy method called.");
         public void actionPerformed(ActionEvent e) {
    try
    // URL myUrl = new URL("simple.htm");
              if ("home".equals(e.getActionCommand( )))
                   fetchURL.showDocument(new URL("simple.htm"),"ButtonResults");
                   AppletContext.showDocument(new URL("simple.htm"),"ButtonResults");
    catch(Exception exept)
    </code>
    the code above is good for one button only. i have made a dozen of these but im just testing one button for now to get the solution right.. the other would be later...
    here's the (main) html file...
    <code>
    <html>
    <head> <title> SKI group </title> </head>
    <body background="bg_fade.gif">
    <center><table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
         <tr>
              <td colspan=11><br></td>
         </tr>
         <tr>
              <td colspan=11><br></td>
         </tr>
         <tr>
              <td width=25><br></td>
              <td width=50 align="center"><img src="house.jpg" width=60 height=50 ></td>
              <td width=25><br></td>
              <td width=50 align="center"><img src="puzzle.jpg" width=60 height=50 ></td>
              <td width=25><br></td>
              <td width=50 align="center"><img src="gears01.jpg" width=60 height=50 ></td>
              <td width=25><br></td>
              <td width=50 align="center"><img src="maze.jpg" width=60 height=50 ></td>
              <td width=25><br></td>
              <td width=50 align="center"><img src="peoplemove.jpg" width=60 height=50 ></td>
              <td width=25><br></td>
         </tr>
         <tr>
              <td width=25><br></td>
              <td width=50 align=center><applet code="TestHomeButton.class" width=120 height=40> </applet></td>
              <td width=25><br></td>
              <td width=50 align=center><applet code="TestVariablesButton.class" width=120 height=40></applet></td>
              <td width=25><br></td>
              <td width=50 align=center><applet code="TestOperatorsButton.class" width=120 height=40></applet></td>
              <td width=25><br></td>
              <td width=50 align=center><applet code="TestFunctionsButton.class" width=120 height=40></applet></td>
              <td width=25><br></td>
              <td width=50 align=center><applet code="TestCrewButton.class" width=120 height=40></applet></td>
              <td width=25><br></td>
         </tr>
         <tr>
              <td colspan=11><br></td>
         </tr>
         <tr>
              <td colspan=12>
                   <iframe name="ButtonResults" src="welcome.htm"
                        width="700" height="500"
                        scroll="0" frameborder="0">
                   </iframe>
              </td>
         </tr>
    </table></center>
    </body>
    </html>
    </code>
    so, once homeButton is clicked it calls on another html file to be shown inside the iframe... unfortunately, it just didnt work :-(
    i am hoping you guys here could help me out and enlighten me...
    thanks, in advance
    Bar

    Try:public void actionPerformed(ActionEvent e) {
        try {
            if ("home".equals(e.getActionCommand()))
                getAppletContext().showDocument(new URL("simple.htm"), "ButtonResults");
        ...Next time please paste your code between &#91;code&#93; &#91;/code&#93; tags with the help of the code button just above the message box.
    It makes the code readable.
    Regards

  • Openning an URL in a new window when the page is submitted, from a pl/sql p

    Hi,
    What I want to do is a procedure (called by an apex process) that opens a new window browser at the URL defined in the procedure.
    I have tried with the following procedure:
    create or replace procedure reportes (par1 NUMBER, par2 NUMBER)
    BEGIN
    htp.htmlOpen;
    htp.headOpen;
    htp.title('Reporte SAF - .: SINERWARE - 2008:.');
    htp.headClose;
    htp.bodyOpen;
    htp.area('0,0,200,400', 'rect', '200.31.86.173/Orden_pedido.jsp?centro_costo='||par1||'&orden_inicial='||par2, NULL, '_blank');
    htp.bodyClose;
    htp.htmlClose;
    END;
    Thanks for any comment.
    Alejandro T.

    I assume your are writting an applet. You can do this by adding a little Javascript to your HTML page. Add this to the HEAD section:
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
      function openURL(url) {
        window.open( url, "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes" );
      } //end openURL
    // End -->
    </SCRIPT>Execute the Javascript using showDocument():
    String url = "http://somewhere.com/" ;
    try {
      getAppletContext().showDocument((new URL("javascript:openURL(\"" + url +"\")"));
    } catch (MalformedURLException me) {
    } //end try

Maybe you are looking for