Hi again, I only need to pass this validation once from my standalone application to my server, i.e. i dont need to maintain it among requests ...
Do you have some piece of code to do this? Thanks! Regards T On 3/30/07, Craig McClanahan <[EMAIL PROTECTED]> wrote:
On 3/30/07, Tatiana Lloret Iglesias <[EMAIL PROTECTED]> wrote: > Hi all, > > I'm using jakarta httpclient classes to generate a Request from a stand > alone application: > > HttpClient client = new HttpClient(); > URL filesURL = new URL(myURL"); > > PostMethod postMethod = new PostMethod(filesURL.toString()); > > File targetFile = new File(path); > Part[] parts = {new StringPart("serverFileName",serverFileName), > new FilePart(targetFile.getName(), targetFile) > }; > > postMethod.setRequestEntity(new MultipartRequestEntity(parts, > postMethod.getParams()) > ); > > > int statusCode1 = client.executeMethod(postMethod); > > My problem is that in the Server side I check Session object: > > private boolean isUserAuthenticated(HttpServletRequest request) { > boolean isAuthenticated = false; > HttpSession session = request.getSession(false); > if(session == null) return false; > if (session.getAttribute(Constants.USER_LOGGED) != null) { > isAuthenticated = true; > } > return isAuthenticated; > } > > How can I put this Constants.USER_LOGGED variable in httpclient request > object? That is not what you actually want to do :-). What you want to do is simulate the way that a browser maintains sessions across requests. Typically, this is done by the server sending a JSESSIONID cookie along with the first response. Your client code will need to pick up that session ID and include it (in a "Cookie" header) on the subsequent request, so that the server will know what session the second request belongs to. Craig > > Thanks! > T > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]