my dog learned polymorphism*
The moose likes Servlets and the fly likes Access to XML parsing after login authorization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Access to XML parsing after login authorization" Watch "Access to XML parsing after login authorization" New topic
Author

Access to XML parsing after login authorization

Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
I want to let the users parse an XML document to let them get data from the database. But before they are allowed to be submitted to the XML document, they have to request a login servlet which do the user authorization and redirects the users to the right XML document builder servlet. I thought about giving the user a login URL, like:

http://www.myDomain.dk/servlet/Login?username=cust1&password=cust2

If the user is authorized the login servlet redirect to the servlet which build the XML document. The XML document is built from i.e. userID which is stored in a session.

The users can parse the XML document with the following code. But how can they do the user authorization, before parsing the XML document:


[ January 10, 2006: Message edited by: Jeppe Fjord ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

If you read any of the tutorials about J2EE Filters, always the first example given is enforcing that the client is logged in.
Jeppe Sommer
Ranch Hand

Joined: Jan 07, 2004
Posts: 270
And can you give me a tip or tell me where you have read about it?

I don�t have any problems with doing the login authorization. I just don� t know how the user can�t get the URL, which the the login servlet has redirected to?

If I choose to hardcode this URL (XML builder URL), then how do I make a request from the above code (an ordinary java XML parser class), to the login servlet?

I have tried to do the login authorization before I want to parse the XML document, but it doesn�t seem to work:

//First open connection to login servlet - the authorization is created and session values stored
java.net.URLConnection launch = new java.net.URL ( "http://www.myDomain.dk/servlet/login?username=cust1&password=cust2" ).openConnection();
launch.connect();
...
//Then parse the XML document
org.jdom.input.SAXBuilder parser = new org.jdom.input.SAXBuilder();
org.jdom.Document doc = parser.build( XMLdocumentURL );
[ January 10, 2006: Message edited by: Jeppe Fjord ]
 
GeeCON Prague 2014
 
subject: Access to XML parsing after login authorization