Hi,

I couldn't understand whether my problem is due to an API issue or a Servlet
Engine implementation issue, thus sending the question to both platforms.

I am using Stronghold 2.4.2(Apache 1.3.6) with JServ 1.1 on Solaris 2.6
platform. My problem is I am losing my session with https.

The ServerName for the http server is host1 and ServerName for the SSL
Virtual Host is host2. I have two servlets , Servlet1 and Servlet2. Servlet1
is initated by calling https://host2/servlet/Servlet1 , and then by using
sendRedirect, it passes the request to Servlet2 by implementing
response.sendRedirect( response.encodeRedirectUrl(
https://host2/servlet/Servlet2 ) ). If the user accepts the cookie, the
system work. However if the user does not accept the cookie, URLRewriting
does not work and the session is lost.

When I put a link on the Servlet1 , point to Servlet2 via
response.encodeURL( https://host2/servlet/Servlet2) instead of sendRedirect,
session tracking works without the cookies. However it doesn' t work with
sendRedirect.

Below you can find Servlet1.java and Servlet2.java. I would appreciate any
help or comment on this topic.

Thanks,
Yalcin

#####################################
Servlet1.java
#####################################
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Servlet1 extends HttpServlet {

    public void init(javax.servlet.ServletConfig config) throws
ServletException {
        super.init(config);
    }

    public void doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) throws ServletException,
IOException {
        doPost(request, response);
    }

    public void doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) throws ServletException,
IOException {
        try {
                HttpSession session = request.getSession(true);
                session.putValue("username", "demo");
                response.sendRedirect(response.encodeRedirectUrl(
"https://host2/servlet/Servlet2" ));
        } catch (Exception e) {
                log(e.toString());
                e.printStackTrace();
        }
    }

###############################################
Servlet2.java
###############################################
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Servlet2 extends HttpServlet {

    public void init(javax.servlet.ServletConfig config) throws
ServletException {
        super.init(config);
    }

    public void doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) throws ServletException,
IOException {
        try {
                HttpSession session = request.getSession(false);
                response.setContentType("text/html; charset=iso-8859-9");
                PrintWriter out = response.getWriter();

                out.println("<html>");
                out.println("<head>");
                out.println("<title>Demo</title>");
                out.println("<meta http-equiv=\"Content-Type\"
content=\"text/html; charset=windows-1254\">");
                out.println("</head>");
                out.println("<body>");
                out.println("<center>TAMAM</center>");
                out.println("<p>" + session.getValue("username") + "</p>");
                out.println("</body>");
                out.println("</html>");
                out.flush();
                out.close();
        } catch (Exception e) {
                log(e.toString());
                e.printStackTrace();
        }
    }

    public void doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) throws ServletException,
IOException {
        doGet(request, response);
    }
}

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to