You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Fusun Eryoldas <FE...@KBSI.com> on 2001/10/17 21:35:03 UTC
application-sevlet communication and authentication question
Hello,
I am using Tomcat 3.2.3 and form based authentication. My question is
about how to do authentication when the client is a standalone java
application. Since it is an application, there is no browser involved.
Therefore, using cookies option would not make any sense.
Following is that what I am doing in my java code for sevlet
communication:
(The name of the servlet which is secured by the form based
authentication is "ListClients")
URL url = new URL("http://localhost:8080/myapplication/ListClients");
URLConnection URLcon = url.openConnection();
URLcon.setDoOutput(true);
URLcon.setUseCaches(false);
URLcon.setAllowUserInteraction(true);
String userSignature = "j_username=" + URLEncoder.encode("joe") +
"&j_password=" +
URLEncoder.encode("pssjoe");
DataOutputStream printout = new
DataOutputStream(URLcon.getOutputStream());
printout.writeBytes(userSignature);
printout.flush();
printout.close();
DataInputStream in = new DataInputStream(URLcon.getInputStream());
String stline;
while((stline = in.readLine()) != null)
System.out.println(stline);
in.close();
Although I send the j_username and j_password to the servlet, the only
thing I can get as a response from the servlet
is my login html page.
I think for some reason, I can not accomplish to create a session.
I would really apprecite If you could help me with this.
Thanks,
Fusun