Discussions
Categories
- 197K All Categories
- 2.5K Data
- 546 Big Data Appliance
- 1.9K Data Science
- 450.8K Databases
- 221.9K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 552 MySQL Community Space
- 479 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.1K ORDS, SODA & JSON in the Database
- 556 SQLcl
- 4K SQL Developer Data Modeler
- 187.2K SQL & PL/SQL
- 21.4K SQL Developer
- 296.3K Development
- 17 Developer Projects
- 139 Programming Languages
- 293K Development Tools
- 110 DevOps
- 3.1K QA/Testing
- 646.1K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 158 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.2K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 19 Java Essentials
- 162 Java 8 Questions
- 86K Java Programming
- 81 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 205 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 468 LiveLabs
- 39 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 175 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 233 Portuguese
need help with passing URL of document into Applet

797160
Member Posts: 75
I have an applet, which is called by the file
file:///home/lyle/Desktop/linkit/hello.html
I am trying to access the URL of this file in my applet. So I tried the line
String completeURL = getDocumentBase().toString();
However, it is not returning the correct value - it returns the path, but not the filename (ie, not the whole URL)
To debug it, I added this line:
answers.append("url = " + completeURL + "\n");
Which returned the value
url = file:/home/lyle/Desktop/linkit/
Can anyone tell me why this is not returning the entire line?
Thanks!
Edited by: lkb3 on Feb 14, 2011 9:40 PM - fixed a typo
file:///home/lyle/Desktop/linkit/hello.html
I am trying to access the URL of this file in my applet. So I tried the line
String completeURL = getDocumentBase().toString();
However, it is not returning the correct value - it returns the path, but not the filename (ie, not the whole URL)
To debug it, I added this line:
answers.append("url = " + completeURL + "\n");
Which returned the value
url = file:/home/lyle/Desktop/linkit/
Can anyone tell me why this is not returning the entire line?
Thanks!
Edited by: lkb3 on Feb 14, 2011 9:40 PM - fixed a typo
Answers
-
lkb3 wrote:That is not the behavior I see here. An SSCCE (http://pscode.org/sscce.html) based on your snippet*.
..Can anyone tell me why this is not returning the entire line?// <applet code='WhereAmIApplet' width='500' height='100'></applet> import javax.swing.*; public class WhereAmIApplet extends JApplet { public void init() { String completeURL = getDocumentBase().toString(); add( new JTextArea( completeURL + "\n" + System.getProperty("java.vm.version")) ); } }
Output from 3 runs.
From TextPad launching as an appletfile:/D:/projects/numbered/all/158WhereAmIApplet/tp028b26.html 1.6.0-b105
From TextPad launching the source in applet viewerfile:/D:/projects/numbered/all/158WhereAmIApplet/WhereAmIApplet.java 1.6.0-b105
From FF, using an applet.htmlfile:/D:/projects/numbered/all/158WhereAmIApplet/applet.html 19.0-b09
* BTW:
1) When posting code, code snippets, XML/HTML or input/output, please use the code tags as described on the 'sticky post' at the top of the forum thread listing - those posts are there for a reason.
2) For better help sooner, post an SSCCE. I might not have had the motivation to write what you had not bothered to add.
Edit 3) Applets are not easy to develop/debug. Someone who is 'New to Java' should probably not be attempting applet development.
Edited by: Andrew Thompson on Feb 15, 2011 5:47 PM -
Andrew,
Thanks for the input on SSCCEs - I'll be sure to do that from now on.
Anyway, the odd thing is that the behavior I described last night was compiled on my Ubuntu (Lucid Lynx) machine at home. When I recompile it here at work, using 1.4.2 on a Win XP machine, that line does return the whole URL. I dont know why it returned the results it did at home; perhaps the issue is Firefox on Linux...
Regardless, all of my users (my app will reside on a corporate intranet) will be on Windows, so I'll see if I can replicate the error here at work...
Edited by: lkb3 on Feb 15, 2011 5:24 AM -
lkb3 wrote:I am guessing the it is not the compiler that matters, but the run-time. Are you using Sun's Java on Ubuntu or that other alternative that everyone recommends against?
..Anyway, the odd thing is that the behavior I described last night was compiled on my Ubuntu (Lucid Lynx) machine at home. When I recompile it here at work, using 1.4.2 on a Win XP machine, that line does return the whole URL.
This discussion has been closed.