Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

Posts: 27
  • Mark post as helpful
  • send pies
  • 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.setRequestProperty("Date", new Date().toString());
con.setRequestProperty("Content-Length", "0");

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 ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!