|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi all,
I'm triing to make a test program that will test all my jsp pages, for that, i have a servlet that initiate the session parameters (for loggin authorisation) and i whant that servlet to right the source code of the jsp files in a .txt. The problem is that the session is reset when i call the jsp to write it down. Here's some part of my code: //here i call the session and set the parameters HttpSession session=request.getSession(true); session.setAttribute("user_name","auser"); //here i just call the jsp file and write it down in result.txt URL urltt = new URL("http://www.myserveur.com/myfile.jsp"); HttpURLConnection connection = (HttpURLConnection) urltt.openConnection(); connection.setDoOutput(true); connection.setDoInput(true); connection.setUseCaches(false); connection.setAllowUserInteraction(true); connection.connect(); InputStream stream = connection.getInputStream(); BufferedInputStream in = new BufferedInputStream(stream); FileOutputStream file = new FileOutputStream("result.txt"); BufferedOutputStream outBF = new BufferedOutputStream(file); int i; while ((i = in.read()) != -1){ outBF.write(i); } can you tel me what's missing??? (this is on a Linux serveur on tomcat) Last edited by AlliosIII : August 12th, 2003 at 11:08 AM. |
|
#2
|
|||
|
|||
|
If you are connecting to a jsp from a servlet and want your session to be available in the jsp you have to pass the session cookie along. Iterate through all your cookies and find the session cookie and add it to the connection object. Make sense?
|
|
#3
|
|||
|
|||
|
Can it be donne without cookies?
It does make sense but we don't use cookies to save the session parameters. If i do that now it will be more than 150 jsp pages that will need to be changed only for my test routine since we whant to keep the authentification methode has it is right know.
Plus, what i really whant is to be able to add the session object to the HttpURLConnection object. (or to find another connection type that takes the session along) You say to add the cookie to the connection, do you have any example on how to do it for me to try to adapt it to the HttpSession object? And thanx for answering |
|
#4
|
|||
|
|||
|
Well i found out a solution to my problem, insted of writting the jsp page from the servlet i include the jsp in the servlet and i write down the servlet from my program
thx for you time ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > Problem with URLconnection and session parameters |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|