I have written a simple HTML browser application using JEditorPane. The setPage() function works great when I give it a simple string or URL object.
However, I have need to add the userid to the HTTP Request so that we can authenticate the user running the application. In looking at the URL JavaDoc the setter that includes the userid is not accessible on the public interface. According to what I have read, it appears that URLStreamHandler is apparently the only entity allowed to modify such data.
I've tried to envision a scenario where I might incorporate that into the JEditPane and setPage() but, I seem to be missing something. So, I'm looking for some guidance on how I might accomplish this. Has anyone accomplished this? Is there a sample or tutorial that I might look at?
Are you using HTTP Authentication? That's covered by java.net.Authenticator. Read this article for the how-to. If you aren't using HTTP authentication and just want to log in to a web app, that has nothing to do with the Java API. The parameters for a request get appended to the url (as with any form post):
In my case the Authenticator object is not an option. We have a situation where another application will need to hit the same URL and cannot support handling a popup for authentication. So, I was researching the URL class and the setters their that allow the userid information to be included in the http request are not exposed. Also, the setPage() method on the JEditorPane does not seem to allow you to access the HTTP request information. What I would like to do is simply set the userid into the HTTP Request. But, I don't see a way to do that using the JEditorPane scenario. Here is a code snipit to give some idea of what it looks like:
"jep" is an instance of JEditorPane. setPage() can take either a java.lang.String or URL object. All you need to do is call setPage() and the page is retrieved. However, I don't know of a way to actually get at the HTTP Request header from here.
Maki Jav [ April 01, 2005: Message edited by: Maki Jav ]