• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to make URL connection to servlet in j_security_check form based authentication

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to make connection to servlet which is residing in tomcat under form based authentication using j_security_check.
The code which i used to read the content from the given URL is shown below.
Actually the servlet is in server1.I am accessing from server2.
URL urlServlet = new URL("https://server1/TestServlet");
HttpsURLConnection con = (HttpsURLConnection) urlServlet.openConnection();
con.setDoOutput(true);
con.setUseCaches(false);
con.setDefaultUseCaches(false);
con.setAllowUserInteraction(true);
con.setRequestMethod("POST");
con.setRequestProperty("Date", new Date().toString());
con.setRequestProperty("Content-Length", "0");
con.setRequestProperty("Content-Type",
"application/xml;charset=UTF-8");

BufferedReader rd = new BufferedReader(new InputStreamReader(con.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
System.out.println("XML is:"+line);
}
When i connect to this URL it will be redirected to login page,since it is in form based authentication using j_security_check.when i print the streams from the URL,the html content of the login page of my application is displayed.I had configured the SSL also.I want to read the content of the URL.Please help me to resolve this issue.
[ August 21, 2008: Message edited by: elay Raja ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic