Maintain session in JSP frame

Hi,
I am having trouble in maintaining session in jsp frames. -
Here is sample code
parent.jsp
<HTML>
<HEAD>
<LINK rel=stylesheet type="text/css" href="defaults.css">
<TITLE>abc</TITLE>
<%     
     String checkAmount = "100.00";
     session.setAttribute("checkAmount", checkAmount);
     System.out.println("checkAmount in ppmain"+session.getAttribute("checkAmount"));
%>
<FRAMESET rows="235,*" frameborder="no" >     
<FRAME NAME="pptop" SRC="top.jsp" frameborder=0 scrolling=no noresize >
<FRAME NAME="ppbottom" SRC="bottom.jsp" frameborder=0 scrolling=no marginwidth=0 marginheight=0 noresize>
</FRAMESET>
</HTML>
top.jsp -
<HTML>
<HEAD>
<LINK rel=stylesheet type="text/css" href="defaults.css">
<TITLE>top</TITLE>
<%     
System.out.println("session in top "+session);
System.out.println("checkAmount in top "+session.getAttribute("checkAmount"));
%>
</HTML>
It is not able to retain session in the top.jsp ( in SOP for session I get different session ID in parent.jsp and top.jsp
This Works well in local but when gets deployed to WAS6 server troubles starts.
Any help is appreciated.
Thanks

When you create URLs, you might want to try using JSTL to rewrite them:
<FRAME NAME="pptop"
       SRC="<c:url value='top.jsp'/>"
       frameborder=0
       scrolling=no
       noresize >
<FRAME NAME="ppbottom"
       SRC="<c:url value='bottom.jsp'/>"
       frameborder=0
       scrolling=no
       marginwidth=0
       marginheight=0
       noresize>Or you can use:
SRC='<%= response.encodeURL("top.jsp") %>'

Similar Messages

  • Maintain session in JSP after using filters

    I have to extend this application to maintain the session , because there are 10 jsp pages in my application.
    When the user logs in , and hits a tab(which should redirect to another jsp page - assume users.jsp) the page is redirected back to the login page (instead of the users.jsp page) because of the filter.
    How do I maintain the session here , so that a user who is logged in (with user name and password) could access the other pages instead of just being redirected back to the login.jsp page.
    this is my filter page
    package com.bea.genesis.tenantmgmt.utils;
    import java.io.IOException;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class FacesRedirectFilter implements Filter {
         public void doFilter(ServletRequest req,ServletResponse res,FilterChain chain)
         throws ServletException, IOException
              HttpServletRequest request = (HttpServletRequest)req;
              HttpServletResponse response = (HttpServletResponse)res;
              //String uri = request.getRequestURI();
              String relativePath = request.getServletPath();
              if ((relativePath.indexOf("/pages/") >= 0) && relativePath.endsWith(".jsf")) {
                   //int length = uri.length();
                   //String newAddress = uri.substring(0, length-3) + EXTENSION;
                   //response.sendRedirect("login.jsf");
                   RequestDispatcher rd = request.getRequestDispatcher("login.jsf");
                   rd.forward(req, res);
              chain.doFilter(request, response);
         public void destroy() {
              // TODO Auto-generated method stub
         public void init(FilterConfig filterConfig) throws ServletException {
              // TODO Auto-generated method stub
    Please reply
    thanks

    Thanks for the reply , How do I test in the filter whether the user is loged in or not.(I dont have clue , how to do tht)
    this is my login Bean ---
    import java.util.Map;
    import javax.faces.context.FacesContext;
    public class LoginBean extends AbstractBean {
         private String loginId;
         private String password;
         private LoginService loginService;
         private LoginValidator loginValidator = new LoginValidator();
         private TenantProfileService tenantProfileService;
         public String getLoginId() {
              return loginId;
         public void setLoginId(String _loginId) {
              loginId = _loginId;
         public String getPassword() {
              return password;
         public void setPassword(String _password) {
              password = _password;
         public LoginService getLoginService() {
              return loginService;
         public void setLoginService(LoginService loginService) {
              this.loginService = loginService;
         *public String login() {*
    *          String authenticationStatus = GenesisConstants.RESULT_FAIL;*
    *          appLogger.enterMethod(this, "login", loginId);*
    *          if (loginValidator.validateData(this)) {*
    *               try {*
    *                    long profileId = loginService.authenticateUser(loginId,*
    *                              password);*
    *                    TenantProfileData tenantProfileData = retrieveTenantProfile(profileId);*
    *                    if (tenantProfileData == null || !tenantProfileData.getStatus().equalsIgnoreCase(*
    *                              GenesisConstants.TENANT_STATUS_ACTIVE))*
    *                         throw new LoginException(*
    *                                   "Tenant profile Not Active for the user.");*
    *                    authenticationStatus = GenesisConstants.RESULT_SUCCESS;*
    *               } catch (LoginException le) {*
    *                    appLogger.error("Error in User Authentication", le.getMessage());*
    loginValidator.addErrorMessage(null, le.getMessage());
    *                    authenticationStatus = GenesisConstants.RESULT_FAIL;*
              appLogger.exitMethod(this, "login", loginId);
              return authenticationStatus;
         public TenantProfileData retrieveTenantProfile(long profileId) {
              appLogger.enterMethod(this, "viewTenant");
              FacesContext facesContext = FacesContext.getCurrentInstance();
              Map<String, Object> sessionMap = facesContext.getExternalContext()
                        .getSessionMap();
              appLogger.debug("profileId==", profileId + "");
              TenantProfileData tenantProfileData = new TenantProfileData();
              try {
                   appLogger.debug("invoking TenantProfileService.getTenantById");
                   tenantProfileData = tenantProfileService.getTenantById(profileId);
                   appLogger
                             .debug("successfully completed TenantProfileService.getTenantById");
              } catch (TenantProfileServiceException te) {
                   appLogger.debug("exception in TenantProfileService.getTenantById");
                   throw new DataException(te.getMessage());
              sessionMap.put("tenantProfileData", tenantProfileData);          
              appLogger.exitMethod(this, "viewTenant");
              return tenantProfileData;
         public TenantProfileService getTenantProfileService() {
              return tenantProfileService;
         public void setTenantProfileService(
                   TenantProfileService tenantProfileService) {
              this.tenantProfileService = tenantProfileService;
    PLEASE HELP
    THANKS

  • How to maintain session in jsp

    Hello Techies,
    I am very new jsp and doing xperimentation in jsp. I am having 3 jsp's namely a.jsp,b.jsp,c.jsp.
    In b.jsp I am having one combo box , after selecting the combo box I want to put the value in session.
    How can I do this one.
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <%@ page language="java" contentType="text/html; charset=iso-8859-1" %>
    <html>
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <title>Untitled Document</title>
       <script language="javascript">
           function ll() {
                   alert("test");
    //            var sel=document.forms[0].rule;
                       document.forms[0].submit();
                   alert("form is submitted")
          </script>
    </head>
    <body>
    <select  name="comboBox" size="1" onchange="ll()">
         <option value="">1</option>
         <option value="">2</option>
         <option value="">3</option>
    </select>
    </body>
    </html>How can I set the selected value in this combo box into session.
    Can u guys help me out in fixing this problem.

    Well you have to submit the form first.
    In the java code:
    String comboValue = request.getParameter("comboBox");
    session.setAttribute("comboValue", comboValue);

  • Regarding maintaining session in flex

    Hello,
              I am developing a flex application which is using jsp for database connectivity. I am using HTTP request for connecting to jsp page and passing and retrieving parameters. Now I wanted to ask how can I maintain session in flex so that I can know which client has logged into the system and on the basis of that can assign privileges to the client. Is it possible in flex and how?Reply needed urgently.
    Thanks in advance.

    Hi a.bhavika,
    There is not specifically any session management in Flex as it runs everything on the client side if at all you want to mainatain you can maintain it on the server side. ...and I think for your case I dont think you need any session managemenet as at the time of login only you can identify which user has logged in to the syetem and based on the user logged in you can load all the previleges of that particular user in the Flex application.
    Check out the links below for your understanding...
    http://www.forta.com/blog/index.cfm/2006/9/24/flex-and-session-state-management
    http://www.assembla.com/wiki/show/romoz/Session_Management_in_Flex
    Thanks,
    Bhasker

  • Maintaining Sessions through Multiple Servlets and Contexts

    Hi,
    I have a webapplication that works like this:
    * User connects to a login servlet on HTTPS
    * Users information is authenticated on HTTPS
    * An object is stored in the session for other servlets to validate the users access
    * Authenticated users are forwarded to an HTTP page where the session is used to make sure they were granted access
    My problem is this....Since I create the session in an HTTPS context, when I am in the HTTP context, I am unable to access the session and constantly get NULL. Is there any way that I can access the session from an HTTP context?

    What you can do is, just login using HTTPS and switch over to HTTP
    and then store data in session.That is true, but what I want in the session is basically a flag on whether or not the user was granted access. I would much rather set all that up on the secure line, and then just access it from the unsecure ones...
    For example, you are creating session using the
    http://testdev:port/index.jsp page.
    If access the same page(with hostname)
    http://10.300.20.18:8080/index.jsp, you can't get the session even
    though both are same web server and same web application. Because the
    browser treats it different sessionI think if you use my above solution with the explicit passing of the jsessionid, you can move from one domain to another and still maintain session. Not positive on that though...

  • Session in JSP page

    Hi all,
    i built a web application now i want to use session in JSP pages to remember some variable such as password and entered date because i need them in later pages and i also don't want to send them via HTML hidden field. I actually don't know how to use session. Can anyone please just tell me how to create a session and store a variable and also how to retrieve the data from the session.
    Another thing is guys can anyone tell me please that say i am user and i selected some items from a HTML select list and i submitted that and logged off the system now when i login later again i want to see those choices selected by default , i know it might have been done by sessions can anyone please tell me.
    THANKS VERY MUCH

    This is the way u can set and retrieve values from session
    <% session.setAttribute("key","value"); %>
    <% String user=(String)session.getAttribute("user");
    %>
    regards
    Shanu

  • How to Handle user Session in JSP

    Help me,
    How to handle user session in JSP.......

    Prakash_Pune wrote:
    tell me some Debugging tech. so i can overcome from my problem.....Do you use an IDE? Any IDE ships with a decent debugger where in you can just execute the code step by step, explore the current variable values and check what exactly is happening. For example Eclipse or IntelliJ. If you don´t use an IDE, then just place some System.out.println() or Logger.debug() statements at strategic locations printing the variables of relevance so that you can track in logs what exactly is happening.
    or tell any other way to find is my page is thread safe or not...Just write correct code and narrow the scope of the variables as much as possible. If you for example assigned the user object to a static variable or as a servlet´s instance variable, then exactly the same user object would be used everywhere in the application. That kind of logical things.

  • Maintaining Session State

    Hello,
    Does anyone know how to maintain session and application variables through server restarts? I want to be able to shutdown and startup my Tomcat server without having the users lose their session and application variables (and consequently, their data and login state).
    Any ideas?
    Thanks!
    -David

    I dont think its possbile since stopping and restarting gets new sessions. Only way that I would know would be to use cookies.
    But then again i dont like the idea of saving passwords in cookies

  • How to clear session in JSP?

    I searched yahoo, and found that it seemed not easy to force invalid the session using jsp, compared to php just three lines:
    session_start();
    session_unset();
    session_destroy();
    How to acheive this using JSP? Must I follow these (quite complex) steps like this one?
    http://sdc.sun.co.jp/javasystem/technote/cluster/jsp.html
    Any simplier method?
    Thx.

    Not at all, it's very simple.
    <%
    session.removeAttribute("attributeName");
    %>
    This HttpSession API document shows all methods that can be called on the session object : http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpSession.html

  • What is the use of session in jsp

    hai,
    what is the use of session in jsp. i cant understand from books. give some practical approach
    thanks

    give some practical approachYou sound like a supervisor ordering for a cup of coffee.
    I DONT TAKE ORDERS !!
    IMAO
    Which book did you refer ? Did you google ?

  • Want to get ApEx session in JSP

    Hi Pals,
    From my ApEx application, I am calling a JSP by providing a direct URL.
    THe JSP does some specific function here.
    If the user get the JSP url by right click and view source, they can very well use this outside my ApEx application.
    I want to apply security like, the JSP url only works inside my ApEx application.
    My thought, if I can share ApEx session with JSP session I can impose the security check in JSP level.
    Any idea would be appreciable.

    Hi,
    Im using below method to call jsp page and passing UserName, application id and Session as
    <iframe src="http://apex.oracle.com/pls/otn/...javaapplication.jsp?userId=&USER.&appId=&APP_ID.&sessId=&SESSION."></iframe>
    Vailidation is done against the table "wwv_flow_sessions$" of schema : flows_030100 ,whether those values are exist in table.
    But if user is already logged into apex application, he can run the jsp independantly taking the url from "view source".
    Im also looking for more solid validation
    Regards,
    Benz

  • Making  a session in jsp.

    I want ti make a session in jsp.
    suppose if any budy can login through login page which is
    www.harshworld.info/login.jsp
    they will just direct open that page
    www.harshworld.info/wallpage.jsp
    then this page will not open . & user will see The login page it self.
    So after making session in jsp what can i do ?
    & how to Do can one help me.
    PL Thanks for Giving time to me

    THk dear
    there's always a session...
    if(session.getAttribute("username") == null) {
    response.sendRedirect("login.jsp");
    return;
    and put the attribute in the session on successful
    login..
    Or look up other security modes.

  • Handling Session in jsp and bean scope

    i have problems with handling session in jsp
    I want to check on all jsp pages
    first thing is session is null
    i want to him to be redirected to first page
    and he should not be able to go ahead
    I tried
    if(session ==null)
    response.sendRedirect("Login.jsp");
    but this does not seem to work
    It is very crtical problem can any one answer
    this asap
    Also i wanted to know that
    I have bean which in turn calls static methods of another class which holds all DomainTable(database tables which do not change frequently)
    Information .
    This is bean is being implemented by me
    in seession scope in a jsp
    Do u guys think it would be goo idea to change
    scop of this bean as Application in jsp
    if so what would be advantages for same
    I would appericate if i could a quick reply on both
    question
    as i am time crunch
    arsh

    You will always get some value of session and your code wont work. At the end of your Login.jsp, you should create a sesssion and store attributes. Check for these attributes in session, rather than checking session==null.

  • Maintain session in Multiple soap calls

    Hi Experts,
    We have an requirement which runs 2 synchronous calls.
    1st synchronous cal is for validating user credentials and
    2nd synchronous call (for successful log in) for uploading data in R/3 system.
    The main task is to maintain session(ex: time 15 mins) .
    1st synchronous call looks like Mobile Application (soap sender)<--->PI<----->(Soap receiver)Active Directory.
    2nd synchronous call looks like Mobile Application (Soap sender)<--->PI<----->(Proxy)R/3 system.
    can you pls let me know how can I achieve this requirement and
    how to maintain session ID, session (is it in PI or in third party) and from where to maintain session.
    Thanks in Adv..

    I am calling multiple web service apis from my bpel process on the same link. The Web services are written such that I always have to call a "login" api first which creates a context that's maintained throughout the session. Thus subsequent ws calls have to be made in the same session because all the other web service apis require the context to be present.
    You can think of this as a stateful SessionBean (sort of).
    The question is does bpel support this?

  • Maintaining session in portal

    Hi,
    I want to maintain session expire time in portal for my iViews both Porta components and Web Dynpro. Where can I set this value.
    Please let me know
    Thanks
    Bobby M

    Hi,
       I'm sorry. Messed it up Go through Web Dynpro application needs to never expire..
    Regards,
    Satyajit.
    Message was edited by:
            Satyajit Chakraborty

Maybe you are looking for