jsp:getproperty always null

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Judy K
    New Member
    • Nov 2006
    • 4

    #1

    jsp:getproperty always null

    Greetings,

    Trying to assign a javabean property and get it in another page with <jsp:getPropert y ....

    I can get it in the same page, but in different page it is always null.

    scope = "session" is in the jsp:usebean tag.

    I am still trying to do this as an alternative to passing query string in URL...

    Any advice greatly appreciated.

    Thanks,
    JK
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by Judy K
    Greetings,

    Trying to assign a javabean property and get it in another page with <jsp:getPropert y ....

    I can get it in the same page, but in different page it is always null.

    scope = "session" is in the jsp:usebean tag.

    I am still trying to do this as an alternative to passing query string in URL...

    Any advice greatly appreciated.

    Thanks,
    JK
    And why not use request.getPara meter()
    or request.setAttr ibute() with request.getAttr ibute?
    They are especially made for passing values values between pages

    Comment

    • Judy K
      New Member
      • Nov 2006
      • 4

      #3
      I am opening a jsp website via Delphi code and passing in parameters in the query string of the URL like this:
      http://sabre/fwb_live/fastweb/html/PreLoad_11_3.js p?custname=lcte st&login=logint est

      This works fine – BUT I really don’t want all those values to be visible because of security concerns, so I am trying to “hide” the custname parameter by using a java bean, so I can reference it later. (I am able to reference that value in the same page.) I am getting the value by using request.getPara meter.

      Then I redirect to a new html page with the first page's onload event without including the custname parameter in the URL The new page is index.html (which uses frames). One of the frames’ src is nav.jsp. In nav.jsp I am trying to get the value back from the bean so I can put it in an XML document and send it on it’s way, but the custname is always NULL! I cannot send you all the code as there are lots of dependencies, but am sending the most pertinent parts.

      If you have any ideas what I am doing wrong, or if you know of a better way to do this, I would be most grateful for advice.

      I am using Internet Explorer 5.0 on a Tomcat 3.0 webserver.


      Thanks very much,
      Judy
      --------------------
      Excerpts from JspUIHelper:

      package com.medcmp.fast web.view;

      import com.medcmp.log. Log;
      import com.medcmp.log. Priority;
      import com.medcmp.util .ComponentHelpe r;
      import com.medcmp.util .StringHelper;
      import java.rmi.Remote Exception;
      import java.text.DateF ormat;
      import java.text.Simpl eDateFormat;
      import java.util.Date;
      import javax.servlet.S ervletRequest;
      import javax.servlet.h ttp.HttpServlet Request;
      import javax.servlet.h ttp.HttpSession ;

      public class JspUIHelper
      {


      (…skipping some…)

      public String getCustname() {
      return(custname );
      }

      public void setcustname(Str ing custname) {
      this.custname = custname;
      }
      ---------------------------------------

      Entire contents of PreLoad_11_3.js p:


      <%@ page errorPage="../../fastweb/jsp/JspException.js p" import="java.ut il.*" %>
      <jsp:useBean id="myJspUIHelp er" class="com.medc mp.fastweb.view .JspUIHelper" sco
      pe="application " />

      <jsp:setPropert y name="myJspUIHe lper" property="custn ame" param="custname " />

      <%
      // add variable to this list
      String id = "";

      // add an if statement to map it in
      if ( request.getPara meter("LogonIDI n") != null ) {
      id = request.getPara meter("LogonIDI n").trim();
      };

      String custname = "";
      if ( request.getPara meter("custname ") != null ) {
      };

      String login = "";
      if ( request.getPara meter("login") != null ) {
      login = request.getPara meter("login"). trim();
      };

      // append it to the URL string
      String x = "index.html?Log onIDIn=" + id + "&login=" + login;
      %>
      <HTML>
      <HEAD>
      <script language=javasc ript type="text/javascript">

      function fwd() {

      location.href = "<%=x%>" ; ---if I comment out this line I can see the property from the getProperty call below so I know the Bean is working
      };


      </script>
      </HEAD>
      <BODY onLoad = "fwd()">

      <jsp:getPropert y name="myJspUIHe lper" property="custn ame" />

      </BODY>
      </HTML>

      -----------------------------------------------------------

      Excerpts from nav.jsp:

      <html><head>
      <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
      <META HTTP-EQUIV="Expires" CONTENT="-1">
      <jsp:useBean id="myJspUIHelp er" class="com.medc mp.fastweb.view .JspUIHelper" />
      <title>Channels </title>
      <SCRIPT LANGUAGE=JAVASC RIPT1.2 TYPE="TEXT/JAVASCRIPT">

      var preload = "";
      var ppathUrl = "";
      var cnam = "";
      if (top.parent.loc ation.search.le ngth > 0) {
      preload= top.location.se arch.slice(0);
      }
      cnam = "<%= myJspUIHelper.g etCustname() %>";
      ppathUrl = "/fwb_live/fastweb/jsp/pPathSeamless10 _3_4.jsp" + preload + "&custnam
      e=" + "<%= myJspUIHelper.g etCustname() %>"; if I change this method to another “get” method in the Bean I get a value
      // MENU
      function selectSubchanne l(channel) {

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by Judy K
        I am opening a jsp website via Delphi code and passing in parameters in the query string of the URL like this:
        http://sabre/fwb_live/fastweb/html/PreLoad_11_3.js p?custname=lcte st&login=logint est

        This works fine – BUT I really don’t want all those values to be visible because of security concerns, so I am trying to “hide” the custname parameter by using a java bean, so I can reference it later. (I am able to reference that value in the same page.) I am getting the value by using request.getPara meter.

        Then I redirect to a new html page with the first page's onload event without including the custname parameter in the URL The new page is index.html (which uses frames). One of the frames’ src is nav.jsp. In nav.jsp I am trying to get the value back from the bean so I can put it in an XML document and send it on it’s way, but the custname is always NULL! I cannot send you all the code as there are lots of dependencies, but am sending the most pertinent parts.

        If you have any ideas what I am doing wrong, or if you know of a better way to do this, I would be most grateful for advice.

        I am using Internet Explorer 5.0 on a Tomcat 3.0 webserver.


        Thanks very much,
        Judy
        --------------------
        Excerpts from JspUIHelper:

        package com.medcmp.fast web.view;

        import com.medcmp.log. Log;
        import com.medcmp.log. Priority;
        import com.medcmp.util .ComponentHelpe r;
        import com.medcmp.util .StringHelper;
        import java.rmi.Remote Exception;
        import java.text.DateF ormat;
        import java.text.Simpl eDateFormat;
        import java.util.Date;
        import javax.servlet.S ervletRequest;
        import javax.servlet.h ttp.HttpServlet Request;
        import javax.servlet.h ttp.HttpSession ;

        public class JspUIHelper
        {


        (…skipping some…)

        public String getCustname() {
        return(custname );
        }

        public void setcustname(Str ing custname) {
        this.custname = custname;
        }
        ---------------------------------------

        Entire contents of PreLoad_11_3.js p:


        <%@ page errorPage="../../fastweb/jsp/JspException.js p" import="java.ut il.*" %>
        <jsp:useBean id="myJspUIHelp er" class="com.medc mp.fastweb.view .JspUIHelper" sco
        pe="application " />

        <jsp:setPropert y name="myJspUIHe lper" property="custn ame" param="custname " />

        <%
        // add variable to this list
        String id = "";

        // add an if statement to map it in
        if ( request.getPara meter("LogonIDI n") != null ) {
        id = request.getPara meter("LogonIDI n").trim();
        };

        String custname = "";
        if ( request.getPara meter("custname ") != null ) {
        };

        String login = "";
        if ( request.getPara meter("login") != null ) {
        login = request.getPara meter("login"). trim();
        };

        // append it to the URL string
        String x = "index.html?Log onIDIn=" + id + "&login=" + login;
        %>
        <HTML>
        <HEAD>
        <script language=javasc ript type="text/javascript">

        function fwd() {

        location.href = "<%=x%>" ; ---if I comment out this line I can see the property from the getProperty call below so I know the Bean is working
        };


        </script>
        </HEAD>
        <BODY onLoad = "fwd()">

        <jsp:getPropert y name="myJspUIHe lper" property="custn ame" />

        </BODY>
        </HTML>

        -----------------------------------------------------------

        Excerpts from nav.jsp:

        <html><head>
        <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
        <META HTTP-EQUIV="Expires" CONTENT="-1">
        <jsp:useBean id="myJspUIHelp er" class="com.medc mp.fastweb.view .JspUIHelper" />
        <title>Channels </title>
        <SCRIPT LANGUAGE=JAVASC RIPT1.2 TYPE="TEXT/JAVASCRIPT">

        var preload = "";
        var ppathUrl = "";
        var cnam = "";
        if (top.parent.loc ation.search.le ngth > 0) {
        preload= top.location.se arch.slice(0);
        }
        cnam = "<%= myJspUIHelper.g etCustname() %>";
        ppathUrl = "/fwb_live/fastweb/jsp/pPathSeamless10 _3_4.jsp" + preload + "&custnam
        e=" + "<%= myJspUIHelper.g etCustname() %>"; if I change this method to another “get” method in the Bean I get a value
        // MENU
        function selectSubchanne l(channel) {
        If you use a form with hidden input fields and use post instead of get for the form method, there will be no data shown in the url

        Comment

        Working...