Web address conversion help...


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Web address conversion help...

  1. #1
    Join Date
    Jan 2005
    Posts
    4

    Web address conversion help...

    Hi,

    I need to be able to call an image from another website. The script I'm using will only work if the images are on my own server and called with a relative address.

    example:

    <PARAM name="image1" value="image1.jpg">


    I need to be able to call the image from an absolute address.

    example:

    <PARAM name="image1" value="http://anotherwebsite.com/image1.jpg">


    Can someone please show me a way to do this. Do I need to use a variable or an other type of code so that my script will work with an absoloute address value.

    Thanks,

    John

  2. #2
    Join Date
    May 2004
    Posts
    219
    Perhaps if you showed us your code that deals with those parameters then someone might be able to help.

    My guess is that you're using a File instead of an URL in your code somewhere.

  3. #3
    Join Date
    Jan 2005
    Posts
    4
    Here's that part of the code:

    --------------------------------------------

    {
    _5 = getImage(getDocumentBase(), "on.gif");
    _4(_5);
    _2.drawImage(_5, _8.width - 18, _8.height - 32, this);
    }

    --------------------------------------------

    {
    _5 = getImage(getDocumentBase(), "off.gif");
    _4(_5);
    _2.drawImage(_5, _8.width - 18, _8.height - 32, this);
    }

    --------------------------------------------

    {
    g.setColor(new Color(_71));
    g.fillRect(0, 0, _8.width, _8.height);
    g.setColor(new Color(_72));
    String s1 = "Loading Image " + Integer.toString(i + 1);
    g.drawString(s1, _9 - fontmetrics.stringWidth(s1) / 2, _10);
    update(_1);
    if(getParameter("image" + Integer.toString(i)) != null)
    {
    _5 = getImage(getDocumentBase(), getParameter("image" + Integer.toString(i)));
    _4(_5);
    _5 = _2(_5, _75, _75);
    System.arraycopy(_20, 0, _81, i * _75 * _75, _75 * _75);
    }

    --------------------------------------------

    Thanks, John

  4. #4
    Join Date
    May 2004
    Posts
    219
    You see, getDocumentBase() returns the location of the applet.

    All you really have to do is replace getDocumentBase()with new URL("http://blah/") or whatever your base is.

    ie:

    getImage(getDocumentBase(), getParameter("image" + Integer.toString(i)));

    becomes

    getImage(new URL("http://blah.com/"), getParameter("image" + Integer.toString(i)));

    or if you want the parameter to contain the entire location you would use the getImage(URL) method as opposed to getImage(URL, String).

    Hope that makes sense.

  5. #5
    Join Date
    Jan 2005
    Posts
    4
    Hi Drain,

    Thanks for the reply, it was very helpfull, but when
    I change the code from:

    _5 = getImage(getDocumentBase(), getParameter("image" + Integer.toString(i)));

    To:

    _5 = getImage(URL url), getParameter("image" + integer.toString(i)));

    I get 1 error saying ')' expected.

    What do I need to change to get this to work.

    The value for "image" must be able to have the full address for any image ex. "http://www.anysite.com/image1.jpg" inserted into the HTML file.

    Thaks in advance,

    John

  6. #6
    Join Date
    May 2004
    Posts
    219
    Read the first part of my post again. The bolded part, specifically.

    When I said getImage(URL) I didn't mean it as literal code, just that you can use the getImage method that takes a single parameter (an URL).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center