File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes how to make URL connection to servlet in  j_security_check  form based authentication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to make URL connection to servlet in  j_security_check  form based authentication" Watch "how to make URL connection to servlet in  j_security_check  form based authentication" New topic
Author

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

elay Raja
Greenhorn

Joined: Jun 10, 2008
Posts: 27
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to make URL connection to servlet in j_security_check form based authentication