Results 1 to 18 of 18
Like Tree2Likes
  • 1 Post By DarrylBurke
  • 1 Post By Norm

Thread: How to get the URL of current page in java class

  1. #1
    Eswaraiah is offline Member
    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0

    Default How to get the URL of current page in java class

    Hi Experts,
    How can we get the URL of currently opened web page/tab in a java class.

    Best regards,
    Eswar

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,303
    Rep Power
    20

    Default Re: How to get the URL of current page in java class

    You can't write spyware in Java.

    db
    Tolls likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default Re: How to get the URL of current page in java class

    In an applet, the getCodeBase() or getDocumentBase() methods

  4. #4
    MonkeyMan is offline Member
    Join Date
    Jan 2012
    Posts
    45
    Rep Power
    0

    Default Re: How to get the URL of current page in java class

    Why isn't it possible?

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default Re: How to get the URL of current page in java class

    Can pigs fly?

  6. #6
    MonkeyMan is offline Member
    Join Date
    Jan 2012
    Posts
    45
    Rep Power
    0

    Default Re: How to get the URL of current page in java class

    Yes, if you got the wits. Just attach a heavy duty rocket on one, then sure. I'd suppose it's the same with java, cept not with a heavy duty rocket. For instance, java may not directly be able to get the currently open webpage from external browsers, but who's to say these browsers don't / can't be made to export said information readily available for java? And this is only one way of going about it. Couldn't you just translate network information from your computer and get the required information that way?

    I don't know much about java, for sure, but I fail to see why this would be impossible when an URL is only a simple String of data.
    Last edited by MonkeyMan; 03-14-2012 at 08:38 PM.

  7. #7
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default Re: How to get the URL of current page in java class

    why this would be impossible
    The contents of the data is not relevant. Getting any byte from any location in any program's memory sounds simple.
    Allan Ocelot likes this.

  8. #8
    MonkeyMan is offline Member
    Join Date
    Jan 2012
    Posts
    45
    Rep Power
    0

    Default Re: How to get the URL of current page in java class

    Does it have to be bytes in memory? Is there no automatic export, API or anything for browsers, or OS interface for your IP traffic you could translate?

  9. #9
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default Re: How to get the URL of current page in java class

    If the bytes are not in memory, where are they?

  10. #10
    MonkeyMan is offline Member
    Join Date
    Jan 2012
    Posts
    45
    Rep Power
    0

    Default Re: How to get the URL of current page in java class

    I mean, do you really have to go get bytes from memory?

    This is just an example. Mozilla firefox could have an addon that exports your current url to a file. Java could pick up that file and make use of it, hence getting the URL.

    Your OS could track your network traffic, see the IPs you are connected to and export them again to a file, where your java could pick it up and make use of it.

    I don't see why you should go tampering with memory and getting bytes, when you could just do with exports.

    All you really have to do is get the applications play nice together. Making addons for browsers that export your current URL every time you change the page shouldn't be an issue as far as I know?
    Last edited by MonkeyMan; 03-14-2012 at 09:28 PM.

  11. #11
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default Re: How to get the URL of current page in java class

    None of that has anything to do with java programming.

  12. #12
    MonkeyMan is offline Member
    Join Date
    Jan 2012
    Posts
    45
    Rep Power
    0

    Default Re: How to get the URL of current page in java class

    It does if you plan on using the URL information in Java. However, if you plan on using java just you fetch the information directly from the source and nothing else, then I could see why it's a problem. However, getting URL data altogether shouldn't be.

  13. #13
    Eswaraiah is offline Member
    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0

    Default Re: How to get the URL of current page in java class

    Thanks for reply.

    I am not using any applet or servlet. I want to get the URL in the simple java class.

  14. #14
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default Re: How to get the URL of current page in java class

    Can you save the URL when the user types it into your program?

  15. #15
    Eswaraiah is offline Member
    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0

    Default Re: How to get the URL of current page in java class

    No, I am not not saving the url.

  16. #16
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default Re: How to get the URL of current page in java class

    How can we get the URL of currently opened
    No, I am not not saving the url.
    If you saved it then you would have it and not need to get it.

  17. #17
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,565
    Blog Entries
    7
    Rep Power
    21

    Default Re: How to get the URL of current page in java class

    Quote Originally Posted by Norm View Post
    Can pigs fly?
    Yes, but only for extremely small distances and very low.

    kind regards,

    Jos ;-)
    cenosillicaphobia: the fear for an empty beer glass

  18. #18
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default Re: How to get the URL of current page in java class

    That must be Dutch pig.

Similar Threads

  1. Replies: 2
    Last Post: 02-29-2012, 08:54 PM
  2. Replies: 2
    Last Post: 08-07-2011, 09:50 PM
  3. Replies: 4
    Last Post: 05-08-2011, 09:00 PM
  4. Replies: 1
    Last Post: 12-16-2010, 02:39 PM
  5. how to Import my Java Class in Jsp Page
    By pos in forum JavaServer Pages (JSP) and JSTL
    Replies: 20
    Last Post: 04-06-2010, 02:51 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •