Session-scope variable for JSP page used in a frame

Hi,
I don't know if there's a way to do this at the same time:
(1)- assign session scope to a variable (in order to be able to retrieve recurrently the previous value each time the JSP is called);
(2)- set its visibility in a way that it could be accessed only by the page that defines it. The JSP is used in a frameset along with an other JSP that can potentially define identical session-scoped variable (You understand why I want to keep them separate)
session.setAttribute():
seems not to be the thing I need
pageContext.setAttribute():
with SESSION_SCOPE, it behaves the same way as session.setAttribute(). with PAGE_SCOPE, condition (1) can't be satisfied.
Does anybody have an idea ?
Thanx in advance.

I can see that you will not want to maintain two different files for every possible page on the site!
It may be possible to do something like <frameset rows="*" cols="50%,*">
  <frame name="content1" src="file.jsp?frame=one" >
  <frame name="content2" src="file.jsp?frame=two" >
</frameset>and then in the jsp<%
String frame=request.getParameter("frame");
session.setAttribute(frame+"AttributeName",attributeValue);
%>This will set up two session attributes - "oneAttributeName" and "twoAttributeName". Depending on how many variables you have, this may prove just as difficult to maintain.
You may end up having to simply pass url parameters between pages to maintain state within the individual frames, which is far from elegant also.
I am interested in how you end up solving this one.

Similar Messages

  • How to use an BPM Instance Variable in JSP page

    Hi All,
    I am using the JSP Presentation, but i don't know how to use an Instance variable in JSP page, that instance already declared in the process. And Can u explain the syntax that to include the JS file into jsp page
    Regards
    Vasu.
    Edited by bpmvasu at 04/03/2007 10:43 PM

    Hi Mariano,
    I'm using JSP presentation too. In "Interactive Component Call" active i'm using "Use JSP presentation", but i only can define one instance variable, i need to add more instance variables. In "Advanced" option of this task, i have the argument mapping .. but i don't understand how to use it.
    I have a instance variable called "genders" of the type String[Int] (Associative Array) and i'm mapping this instance variable in "Arguments Show In" option of the advanced option of JSP presentation. In JSP presentation i have the code:
    <select <f:fieldName att="person.gender"/>>
                   <c:forEach var="gender" begin="0" items="${genders}" varStatus="status">
                        <c:choose>
                             <c:when test="${person.gender == gender}">
                                  <option value="<c:out value="${gender}"/>" selected="true"><c:out value="${gender}"/></option>
                             </c:when>
                             <c:otherwise>
                                  <option value="<c:out value="${gender}"/>"><c:out value="${gender}"/></option>
                             </c:otherwise>
                        </c:choose>
                   </c:forEach>
              </select>And in my screenflow i have the code:
    genders[0] = "Male"
    genders[1] = "Female"But when i run my application, i have the error: "The task could not be successfully executed. Reason: 'java.lang.ClassCastException: java.lang.Integer'."
    What's the problem?

  • Session scope variables and weird behaviour of AdfContext()

    Hello,
    what is the best method and correct API to create a session scope variable?
    I am currently using ADFContext().getCurrent().getSessionScope().get()/put(), but it looks like it has some problems: for some unkown reasons I loose the variable, that is get() returns null when called from a method of a (overridden)ViewRowImpl. Why does this happen?
    Thanks you in advance

    There are a couple of ways you can set values on a sessions scope but I would have to question if you really need a scope as high as session to accomplish what you want to do. At any rate, you should be able to store the value using the method you described but you could also try setting it using EL by using the setExpressionValue and resolveExpression methods in JSFUtils.java (you can find this in the latest fusion demo application). JSFUtils also has a getFromSession and storeOnSession that you could try.
    With all that said I don't think it is good practice to access scope variables from your model layer. You should write your method in the ViewRowImpl class to accept the value as a method parameter and then pass the value in through the binding layer or when invoking the method from your bean class.

  • Unable get complete filepath from jsp page using request.getParameter()

    Hey all,
    i am actually trying to get the selected file path value using request.getParameter into the servlet where i will read the (csv or txt) file but i dont get the full path but only the file name(test.txt) not the complete path(C:\\Temp\\test.txt) i selected in JSP page using browse file.
    Output :
    FILE NAME : TEST
    FILE PATH : test.txt
    Error : java.io.FileNotFoundException: test.txt (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:106)
    at java.io.FileReader.<init>(FileReader.java:55)
    at com.test.TestServlet.processRequest(TestServlet.java:39)
    at com.test.TestServlet.doPost(TestServlet.java:75)
    JSP CODE:
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>DEMO SERVLET</title>
    </script>
    </head>
    <body>
    <h2>Hello World!</h2>
    <form name="myform" action="TestServlet" method="POST"
    FILE NAME : <input type="text" name="filename" value="" size="25" /><br><br>
    FILE SELECT : <input type="file" name="myfile" value="" width="25" /><br><br>
    <input type="submit" value="Submit" name="submit" />
    </form>
    </body>
    </html>
    Servlet Code :
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException, FileNotFoundException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try {
    String filename = request.getParameter("filename");
    out.println(filename);
    String filepath = request.getParameter("myfile");
    out.println(filepath);
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Servlet TestServlet</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h1>Servlet TestServlet at " + request.getContextPath() + "</h1>");
    if (filepath != null) {
    File f = new File(filepath);
    BufferedReader br = new BufferedReader(new FileReader(f));
    String strLine;
    String[] tokens;
    while ((strLine = br.readLine()) != null) {
    tokens = strLine.split(",");
    for (int i = 0; i < tokens.length; i++) {
    out.println("<h1>Servlet TestServlet at " + tokens[i] + "</h1>");
    out.println("----------------");
    out.println("</body>");
    out.println("</html>");
    } finally {
    out.close();
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    Needed Output :
    FILE NAME : TEST
    FILE PATH : C:\\Temp\\test.txt
    Any suggestions Plz??

    As the [HTML specification|http://www.w3.org/TR/html401/interact/forms.html] states, you should be setting the enctype to multipart/form-data to be able to upload files to the server. In the server side, you need to process the multipart/form-data binary stream by parsing the HttpServletRequest#getInputStream(). It is a lot of work to get it to work flawlessly. There are 3rd party API's around which can do that for you, such as [Apache Commons FileUpload|http://commons.apache.org/fileupload] (carefully read the User Guide how to use it).
    You can also consider to use a Filter which makes use of the FileUpload API to preprocess the request so that you can continue writing the servlet code as usual. Here is an example: [http://balusc.blogspot.com/2007/11/multipartfilter.html].

  • Insert data into table from JSP page using Entity Beans(EJB 3.0)

    I want to insert data into a database table from JSP page using Entity Beans(EJB 3.0).
    1. I have a table 'FRIENDS', (in Oracle 10g database).
    2. It has two columns, 'NAME' and 'CITY'. Both have datatype strings(varchar2).
    3. Now from a JSP page, having two textfields, 'NAME' and 'CITY', I want to insert data into table 'FRIENDS'.
    4. In between JSP and database is a Entity Bean(EJB 3.0) and a stateless session bean.
    5. I am using JDev as editor.
    Please provide me code ASAP or link with similar example.
    Thank you.
    Anurag

    Hi,
    I am also trying that scenario. So u can
    Post the jsp form data to a Servlet which will act as a Controller.
    In the servlet invoke the business method.
    Similar kind of app is in www.roseindia.net
    Hope this would help u.
    Meanwhile if u get any optimal solution, pls post it.
    Thanks,
    Happy Java Coding.

  • Can we create a pivot table of Excel in a JSP page using POI

    Hello,
    I want to know whether we can create a pivot table of excel sheet in a jsp page using POI package from apache.
    thank you.

    Hi Alex,
    Many thanks for replying.
    I followed the link, but unable to get correct output.. I have shared the template earlier. I can share the template once again.
    It would be grateful if you give me share the working template with table of content.

  • Help needed to create a master-detail JSP page using OAF.

    I like to create a master-detail JSP page using OAF. If any help or guide will be appreciate.
    - Kausik

    A Master Detail Page is a basically a game between two VOs(Master and Detail mostly connected through a View Link). You can also have a look at the View Link section in the Dev guide. Page Layouts is one thing which you can take a call yourself.
    Regards
    Sumit

  • How to do transactions in jsp pages using Java & MySQL ?

    Hi,
    I'm a newbie..
    I'd like to know "How to do transactions in jsp pages using Java & MySQL ?"
    Platform: Windows XP, Apache Tomcat 5.5, MySQL 5, Java bean without EJB
    what are the the different types of transactions? Differences between them?Pls provide examples?
    Which among them is the best method to implement a transaction?
    Pls help me...
    thnx in advance...

    http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html

  • Variable for start page number?

    I have a collection of indesign documents collated in a book.
    I want to implement a footer that looks like:
    "Start Page - Last Page"
    "750 - 763"
    where Start Page is begining of the beging of the constituent indesign document and last page is the end of the document.
    I can only find a variable for Last Page. Where the start page variable?

    But the Current Page Marker would only be the correct starting page at the very first page of each section! All next pages will show, well, the Current Page ...
    There is no variable for this, it seems. A cross-reference might work -- initally, it's more work, but at least it will update automatically as you move pages around. Point against is, you would need to create a new master page for each article! (Assuming your footer is on a master page.)
    I don't see a good solution out of the box.

  • Resizing pixs for web page use

    I have resized the photos to use on MS Frontpage but when the thumbnails are clicked on to be enlarged in the web page they are still too large. How do I make photos usable for web page use?

    What version of Elements are you using? How are you now going about creating the thumbnails and larger images? What size are you making the large ones? I suspect all you need to do is change the width and height parameters to something smaller.

  • Documentation for JSP pages

    hi,
    i am trying to do documetation for jsp pages, but i not successed.
    can someone clear this up for me? thanks!

    Try the Java developer section of the forums. You're not too likely to get an appropriate response in the SRSS area :-)

  • Save option for jsp page

    hi all,
    In my project am including a html page in jsp.Now i want to save the html page only.Please any body help me to how to give save option for jsp page.
    Thanks in advance.
    mohan :)

    you can save it in with browser "save as"

  • How to use a session, created in a jsp page, in a php page

    Hello, forgive me for the newbie question.
    Here is my problem:
    I want to have a jsp page create a session, set some session variables and then redirect to a php page which will access those same session variables.
    I have the redirection worked out, but I can't seem to find out how to use the jsp session in my php script.
    Is this possible at all, and if so, how does it work?

    Note that javascript runs on the client side, and JSP runs on the server. JSP and the session objects are NOT available to javascript in reaction to the user.
    If this function is called only when the page is first created, not when the user interacts with the page, or if you want that value to be constant with respect to the javascript, then you can do this:
    <%
      String someValue = (String)session.getAttribute("theAttributeName");
    %>
    <script type="text/javascript">
         Calendar.setup({inputField:"f_date_dfFirstPmtDate",
                                              button:"f_trigger_dfFirstPmtDate",
                                             singleClick:true,
                                              ifFormat:<%=someVale%>});
    </script>

  • Need a fast answer... passing javascript variable to jsp page (how to use)

    This test application has 3 frames.
    I'm assigning a value "stuff" to a variable ("testfield1") in a javascript function ("getTest") that exists inside an html frame (testpage1.html)
    Then, I click on the "test submit" hypertext link to pass the value of "testfield1" to the JSP frame (testpage2.jsp) by invoking a function ("getData") in "testpage2".
    In function ("getData"), I am passing the variable "testfield1" as a parameter to the "getData" function in "testpage2".
    In "testpage2" - in the ("getData" function) I try to assign the value of the variable "testfield1" to another variable called "testfld1".
    Then, I try to extract the value of "testfld1" into a variable called "tstfld1" in a JSP scriptlet
    ....I.E. [ String tstfld1  = request.getParameter("testfld1");  ]
    But, the value is apparently not passed successfully, as tstfield1 appears to be "null".
    Can anyone explain what I'm doing incorrectly?
    The code for this test app is below...
    ********testpage0 - the parent frame*********
    <HTML>
    <HEAD>
    <TITLE>GlobalView Reports and Trending Menubar</TITLE>
    </HEAD>
    <FRAMESET FRAMEBORDER="0" ROWS="15%,85%">
    <FRAME SRC="testpage0.html" NAME="testhtmlparent">
    <FRAMESET FRAMEBORDER="0" COLS="23%,77%">
    <FRAME SRC="testpage1.html" NAME="testhtml">
    <FRAME SRC="testpage2.jsp" NAME="testjsp">
    </FRAMESET>
    </FRAMESET>
    </HTML>
    *******testpage1.html********
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <html>
         <head><title>testpage1</title>
         <link rel="stylesheet" type="text/css" href="./standard.css">
              <script LANGUAGE="JavaScript">
              parent.frames[2].location = "blank.html";
              function getTest(reportType)
                   testfield1 = "stuff";
                   alert("testpage1.html...testfield1=" + testfield1 + ", reportType=" + reportType);
                   parent.frames[2].location = "testpage2.jsp";
                   parent.frames[2].getData(testfield1);
                   return;
              </script>
         </head>
         <body bgcolor="#FFFFFF" text="#000000">
              <form name="reportRange">
                   <center>
                        <fieldset style="padding: 0.5em" name="customer_box">
                        <table cellpadding="0" cellspacing="0" border="0">
                             <tr class="drophead">
                                  <td valign="top" height="0" ><span class="drophead">
                                       test submit
                                  </td>
                             </tr>
                        </table>
                        </fieldset>
                   </center>
              </form>
         </body>
    </html>
    *******testpage2.jsp*********
    <%@ page language="java" import="java.io.*, java.util.*" errorPage="error.jsp" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <html>
         <head>
         <title>testpage2</title>
         <script language="JavaScript">
              function getData(testfield1)
                   alert("testpage2.jsp...testfield1=" + testfield1);
                   document.pageData.testfld1.value = testfield1;
                   document.pageData.submit();
         </script>
         </head>
         <body>
              <%
                   String error;
              %>
              <div id="HiddenForm">
                   <form name="pageData" method="post" action="testpage2.jsp" target="_self">
                   <input type="hidden" name="testfld1" value="0">
              </form>
              </div>
              <%
                   String tstfld1 = request.getParameter("testfld1");
              %>
              <P> testfld1 = <%= tstfld1 %> </P>
         </body>
    </html>

    parent.frames[2].getData(testfield1); is in testpage1.html
    so in the document.pageData.testfld1.value = testfield1; document = testpage1.html( not testpage2.html)
    modifying the getData to accept the document object, and refering this object to parent.frames[2].document may help you.
    good Luck ....

  • Problem connecting oracle database to jsp pages using Apache Tomcat server 8.0

    Well...I tried too many things..googled so many times..but still could not find solution to my problem.
    I use windows 8 Enterprise Edition(if this has to do something with the problem)
    Oracle 11.2.0
    Apache Tomcat server 8.0
    JDK 1.7
    My oracle is installed in the D: drive and tomcat in c:. i copied the ojdbc6.jar file from oracle to lib directory of tomcat server.
    Then i set  CLASSPATH in environment variables as "C:\Program Files\Apache Software Foundation\Tomcat 8.0\lib\ojdbc6.jar" in system variables
    My path variable is set as "C:\Program Files\Java\jdk1.7.0_02\bin".
    My program is as follows in notepad:
    <%@ page import="java.sql.*" %>
    <html>
    <body>
    <%
    Connection conn;
    Statement st;
    ResultSet rs;
    try{
    new oracle.jdbc.driver.OracleDriver();
    String dbURL="jdbc:odbc:oracle:thin:@localhost:1521:XE";
    String userId="system";
    String pwd="moon";
    conn=DriverManager.getConnection(dbURL,userId,pwd);
    st=conn.createStatement();
    rs= st.executeQuery("SELECT * FROM login");
    while(rs.next())
    System.out.println(rs.getString(1)+""+rs.getString(2));
    catch(Exception e){}
    %>
    </body>
    </html>
    I get too many errors then
    eroors
    org.apache.jasper.JasperException: An exception occurred processing JSP page /page2.jsp at line 14
    11: String userId="system";
    12: String pwd="moon";
    13:
    14: conn=DriverManager.getConnection(dbURL,userId,pwd);
    15: st=conn.createStatement();
    16:
    17: rs= st.executeQuery("SELECT * FROM login");
    Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:347)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    root cause
    javax.servlet.ServletException: java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:905)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:834)
         org.apache.jsp.page2_jsp._jspService(page2_jsp.java:102)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:347)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
         org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    Nothing solved this problem.

    >> Nothing solved this problem.
    Can't fix a problem 'till an actual problem is identified.
    >> ODBC Driver Manager ... Data source name not found
    That appears to be ODBC drivers looking for a DSN (Data Set Name). If it wants a DSN, the DSN has to be specified in the code, and the DSN has to be configured in the windows host ODBC applet. So that is at least two squirrels to get in the right tree before moving forward. A ...host:...[port:]SID|service name are some of the bits needed in a jdbc connect string, and that is in no way related to DSNs. A Whole Different Animal. If it wants a DSN that might be what needs to go in the URL bit.
    And ODBC setups can be confusing, especially if an x64 OS is in the mix- if that is the case there are two different ODBC configuration applets, one for x64 the other for x86, and if one gets as far as talking to an actual database it might toss an architecture error. Only way to fix that "problem" is *delete* the ODBC DSN and then run the correct (maybe the x86) ODBC config utility, and set up the DSN. Again.

Maybe you are looking for