fragment and query part of URL in applet?

  • Thread starter Andrew Thompson
  • Start date
A

Andrew Thompson

How can I get the fragment and query part of the URL in an applet?

The only URL's that seem to be offered are document
base and code base.

You can look at these URL's, I have a page at..
http://www.physci.org/codes/java/docbase.html
that shows the applet who's code can be seen..
http://www.physci.org/codes/display.jsp?fl=/codes/java/DocBase.java

I was hoping to get the fragment/query string
when I try URL's like..
http://www.physci.org/codes/java/docbase.html#3
http://www.physci.org/codes/java/docbase.html?ans=21
...but both query and fragment show as 'null'.

Is there any way to read these parts of the
URL from inside an applet?
 
S

Sudsy

Andrew Thompson wrote:
I was hoping to get the fragment/query string
when I try URL's like..
http://www.physci.org/codes/java/docbase.html#3
http://www.physci.org/codes/java/docbase.html?ans=21
..but both query and fragment show as 'null'.

Is there any way to read these parts of the
URL from inside an applet?

Piece of cake, Andrew. Look at the java.net.URL class. Two
methods of interest there: getRef() and getQuery(). In your
examples URLs getRef() would return "3" for the first and
getQuery() would return "ans=21" for the second. Just
instantiate a new URL with your String as the constructor.
 
A

Andrew Thompson

Sudsy said:
Andrew Thompson wrote:


Piece of cake, Andrew. Look at the java.net.URL class. Two
methods of interest there: getRef() and getQuery(). In your
examples URLs getRef() would return "3" for the first and
getQuery() would return "ans=21" for the second.

I think I've pretty much got that..
....Just
instantiate a new URL with your String as the constructor.

But this I don't quite get, it is not 'my' String yet,
it is irritatingly close, in the URL that the user
surfed in on and (just to clarify) I need to get
the fragment and query parts from _inside_ the
applet, with no help from external scripts such
as cgi, jsp etc..*

Have I missed something in what you are
saying Sudsy? (Or have I failed to clearly
outline the constraints ..again)

* ultimately I need to use this from pages that
are raw html, with no server side magic available.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top