Jsp:setProperty

Well
I like to use one bean for different jsps with different properties.
I don't want to have setters and getters properties, I would like a HashMap with the property-values.
Could I overwrite jsp:setProperty tag?
Or it will be better to use a custom constructor with HTTPServletRequest param?
Thanks

Try the following forum (about JSP technology)
http://forum.java.sun.com/forum.jspa?forumID=45

Similar Messages

  • jsp:setProperty .. method throws null pointer exception...

    my simple jsp page :
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%--
    The taglib directive below imports the JSTL library. If you uncomment it,
    you must also add the JSTL library to the project. The Add Library... action
    on Libraries node in Projects view can be used to add the JSTL 1.1 library.
    --%>
    <%--
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    --%>
    <!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>JSP Page</title>
        </head>
        <body>
        <h1>JSP Page</h1>
        <jsp:useBean id="user1" class="com.netman.beans.UserBean">
            <jsp:setProperty name="title" property="title" />
            <jsp:setProperty name="name" property="name" />
        </jsp:useBean>
        Name : <%= user1.getName() %><br>
        Title : <%= user1.getTitle() %>
        </body>
    </html>
    // -- my bean class -- //
    package com.netman.beans;
    public class UserBean
        private String name;
        private String title;
        /** Creates a new instance of UserBean */
        public UserBean()
        public void setName(String name)
            this.name = name;
        public String getName()
            return name;
        public void setTitle(String title)
            this.title = title;
        public String getTitle()
            return title;
    }when I try to view the jsp page, i am getting the following exception :
    org.apache.jasper.JasperException: Exception in JSP: /test.jsp:25
    22: <h1>JSP Page</h1>
    23:
    24: <jsp:useBean id="user1" class="com.netman.beans.UserBean">
    25: <jsp:setProperty name="title" property="title" />
    26: <jsp:setProperty name="name" property="name" />
    27: </jsp:useBean>
    28: Name : <%= user1.getName() %><br>
    Stacktrace:
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    org.apache.jasper.JasperException
         org.apache.jasper.runtime.JspRuntimeLibrary.internalIntrospecthelper(JspRuntimeLibrary.java:359)
         org.apache.jasper.runtime.JspRuntimeLibrary.introspecthelper(JspRuntimeLibrary.java:306)
         org.apache.jsp.test_jsp._jspService(test_jsp.java:68)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    java.lang.NullPointerException
         org.apache.jasper.runtime.JspRuntimeLibrary.internalIntrospecthelper(JspRuntimeLibrary.java:320)
         org.apache.jasper.runtime.JspRuntimeLibrary.introspecthelper(JspRuntimeLibrary.java:306)
         org.apache.jsp.test_jsp._jspService(test_jsp.java:68)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    and my request URL is http://localhost:8080/TestApp/test.jsp?title=Super&name=Great
    what could be the problem?

    how stupid i'm..
    instead of using the bean name in setProperty I have used the property name...
    !!!

  • Jsp:setProperty in WebLogic 6.0

    Hi,
              We are using the WebLogic Web container with the Apache server and we
              have encountered a problem with the <jsp:setProperty> and
              <jsp:getProperty> tags. We are using WebLogic 6.0sp1.
              Reading the newsgroups, I noticed that this tag did not work in the
              previous versions of WebLogic and I was wondering if it has been fixed
              in 6.0sp1. Here's the snippet of JSP page that I use:
              <jsp:useBean id="beanName" scope="session"
              class="com.imoney.aplications.BeanClass">
              <jsp:setProperty name="beanName" property="userId" value='<%=
              request.getParameter("userId") %>' />
              </jsp:useBean>
              The problem is that the property userId of the bean with name beanName
              is not set by this tag. The JSP page compiles properly. The bean
              instance beanName is unique in the user session context.
              Thank you for any help,
              Brenda.
              [att1.html]
              

    Hi,
              We are using the WebLogic Web container with the Apache server and we
              have encountered a problem with the <jsp:setProperty> and
              <jsp:getProperty> tags. We are using WebLogic 6.0sp1.
              Reading the newsgroups, I noticed that this tag did not work in the
              previous versions of WebLogic and I was wondering if it has been fixed
              in 6.0sp1. Here's the snippet of JSP page that I use:
              <jsp:useBean id="beanName" scope="session"
              class="com.imoney.aplications.BeanClass">
              <jsp:setProperty name="beanName" property="userId" value='<%=
              request.getParameter("userId") %>' />
              </jsp:useBean>
              The problem is that the property userId of the bean with name beanName
              is not set by this tag. The JSP page compiles properly. The bean
              instance beanName is unique in the user session context.
              Thank you for any help,
              Brenda.
              [att1.html]
              

  • JSP 1.2 and jsp:setProperty

    Has anyone got an idea why they decided to change the way the tag jsp:setProperty is handled?
    In the JSP 1.1 specification, the condition to be checked before calling a single property set method was that the request contained the corresponding parameter, no matter what its value was, and the generated code would look something like this
    String s1 = request.getParameter("example");
    if (s1 != null) setExample(s1);
    In the JSP 1.2 specification, it says the property is set only if the corresponding parameter' s value is not an empty string, as in
    String s1 = request.getParameter("example");
    if (s1 != null && s1.length() > 0) setExample(s1);
    Which is what it would do with the setProperty with property="*", according to the JSP 1.1 specification.
    This will cause me some trouble, because I will have to change my JSPs code in order to have bean variables set to empty string when the user doesn't input any value in the form (with beans having scope "session", of course).

    I have not found any reasonable explaination for this.
    The easiest fix that I could think of was on my JSP
    pages before I submit I check to see if the value of
    the field is "", if it is I set the value to
    "emptyString". On the bean side I check the value of
    the field property passed to see if it is
    "emptyString" if it is I set it to "".
    But this all seems an annoying nuisance when an empty
    string is a perfectly valid value.I think I will fix it by having a reset method called in every JSP containing a form after the form itself has been "written" on the output stream with its fields' values. The thing is that I can't really find a good reason for this change they made: I can't believe there's a developer out there who would find this an improvement. The only thing I can think of is that they wanted to make the setProperty for a single property and the setProperty with property="*" have the same behaviour (the one I don't like).

  • Prob with jsp setProperty

    Dear fouramites,
    I am using jsp SetProperty standadr action tag to set from values to beans. In update when I am changing any form field value it is working fine but when I am deleting the form field value the previous value is being set to bean.
    What is the solution to this problem?
    Thanks & Regards
    Kavyaanjali Jena

    Dear Ram,
    I am using the following code for both save and update functionality.
    <html>
    <%@ page session="true"%>
    <%@ page language="java" %>
    <%@ page import="models.*"%>
    <%@ page import="beans.*"%>
    <%@ page import="java.util.*"%>
    <%
    <jsp:useBean id="DATA_MODEL" scope="session" type="models.BeanInterface" />
    <jsp:setProperty name="DATA_MODEL" property="*"/>
    <jsp:forward page="/servlet/FrontController" />
    </html>
    When I change the value This code could set value to bean but when I totally delete the value it could not set null to bean but old value is retained.
    I am using FrontController architecture.
    Thanks & Regards
    Kavyaanjali Jena

  • How to deal empty field with jsp:setProperty ...

    Ive come across a bug in what I've done so far, not sure if its because of my approach...
    I sucessfully store a value entered in a text field in a bean without any problems, and navigate back to the page where the value re-appears (via html, not relying on the browser). The problem is, if I edit that field to be blank, resubmit, then navigate back, the old value returns.
    As far as I can tell, this is due to my jsp interpreting the input as null (ie. no input) and not changing the tag. IE sends the parameter as myPage.jsp?para1=&para2=some+value as it should (where para1 is the input in question).
    I use the 'parameter="*"' usage of jsp:setProperty - is that a problem? Does this usage of setProperty not allow for setting values back to "" ? If so, how can i overcome this problem without losing the benefits of using <jsp:setProperty name="myBean" property="*">, that is, you can store all property values in javaBean in one go, instead of repeatly using <jsp:setProperty name="myBean" property="myProperty" value="myValue"> for each property.

    hi,
    first clearly tell u' r problem and then only any one can help u.
    we are not unable to understand u'r query. it's like a Composition.
    Bala
    Message was edited by:
    art84

  • Can any one tell me how param is used in Jsp:setProperty ?

    Hi Can anyone please explain me with example how param attribute is used in <jsp:setProperty>?
    I have gone through the java doc but it still not clear to me....

    Try the [JSP syntax reference|http://java.sun.com/products/jsp/syntax/2.0/syntaxref2025.html#8856]
    It is very rare that you would use the param attribute, as most times you have your incoming parameter and bean property having the same name.
    Example:
    Say you navigate to http://localhost:8080/myApp/myPage.jsp?username=Bob
    That sends a request parameter "username" with the value "Bob"
    If we have a bean which also has a property username (getUsername(), setUsername()) (ie the property and the parameter have the same name) you can use the following jsp code:
    <jsp:useBean id="user" class="com.mypackage.User"/>
    <jsp:setProperty name="user" property="username">Translates approximately into
    User user = new User();
    user.setUsername(request.getParameter("username"));If instead the bean had a property "username" but the parameter was "userId"
    <jsp:useBean id="user" class="com.mypackage.User"/>
    <jsp:setProperty name="user" property="username" param="userId">
    User user = new User();
    user.setUsername(request.getParameter("userId"));Cheers,
    evnafets

  • ValueBound() valueUnbound() for every jsp:setProperty .../

    Hi.
              My helper class (implementing HttpSessionBindingListener) is put into
              the HttpServletSession.
              What I want is valueBound()/valueUnbound() on creation/deletion of the
              session.
              The following code:
              <jsp:useBean id="usession" scope="session"
              class="net.icteam.frame.session.UserSession"/>
              <jsp:setProperty name="usession" property="httpRequest"
              value="<%=request%>"/>
              <jsp:setProperty name="usession" property="httpResponse"
              value="<%=response%>"/>
              fires a valueBound()/valueUnbound() for every(!) <jsp:setProperty.../>
              My Question:
              Is this normal behaviour?
              Btw, the following code behaves normal(?):
              <jsp:useBean id="usession" scope="session"
              class="net.icteam.frame.session.UserSession"/>
              <%
              usession.setHttpRequest(request);
              usession.setHttpResponse(response);
              %>
              regards,
              Roman
              

    Sounds like the correct behavior to me. Is there some specific thing that
              you are trying to do?
              Peace,
              Cameron Purdy
              Tangosol Inc.
              << Tangosol Server: How Weblogic applications are customized >>
              << Download now from http://www.tangosol.com/download.jsp >>
              "Roman Heinz" <[email protected]> wrote in message
              news:[email protected]...
              > Hi.
              >
              > My helper class (implementing HttpSessionBindingListener) is put into
              > the HttpServletSession.
              >
              > What I want is valueBound()/valueUnbound() on creation/deletion of the
              > session.
              >
              > The following code:
              >
              > <jsp:useBean id="usession" scope="session"
              > class="net.icteam.frame.session.UserSession"/>
              > <jsp:setProperty name="usession" property="httpRequest"
              > value="<%=request%>"/>
              > <jsp:setProperty name="usession" property="httpResponse"
              > value="<%=response%>"/>
              >
              > fires a valueBound()/valueUnbound() for every(!) <jsp:setProperty.../>
              >
              > My Question:
              >
              > Is this normal behaviour?
              >
              >
              > Btw, the following code behaves normal(?):
              > <jsp:useBean id="usession" scope="session"
              > class="net.icteam.frame.session.UserSession"/>
              > <%
              > usession.setHttpRequest(request);
              > usession.setHttpResponse(response);
              > %>
              >
              > regards,
              > Roman
              

  • Question abt jsp:setProperty property="*" behavior

    Hi,
    I am trying to use the following tag
    <jsp:setProperty name="formBean" property="*"/>
    what this supposed to do is that if you have a bean which has same property names as your html form then instead of setting each property one by one this maps all the bean properties and assign the values.
    However when I tried that it works as suggested but then I change a field name in my bean and recompile and run the jsp again, but it still works. I am not sure whether it is some kind of caching issue? I would think it shoould not set the form values as the bean field name doesn't match up with the form's property name. Please advice

    I believe that the mechanism uses the bean's method names, not the field names, to determine what to call when you do property="*". so you can have the following
    class MyBean{
    String addr;
    public void setAddress( String str ){
    addr = str;
    when you do this:
    <jsp:setProperty name="bean" property="address"/>
    it calls setAddress( String ).

  • jsp:setProperty doesn't work with short properties

    Hi,
              Setting bean properties doesn't work with properties that are of type short.
              Any ideas what's going on? I'm using WLS 6.1SP1 on W2K.
              --John
              <jsp:useBean id="test" scope="session" class="test.Test" />
              <jsp:setProperty name="test" property="*" />
              -- Test.java
              package test;
              * @author john
              public class Test {
              /** Creates new Test */
              public Test() {
              public short getShort() {
              return 0;
              public void setShort(short val) {
              Produces the following error while attempting to compile the jsp:
              Compilation of
              'C:\bea\wlserver6.1\config\cleanoffer\applications\.wlnotdelete\WEB-INF\_tmp
              warCleanOffer Server_CleanOffer Server_test\jsp_servlet\__test.java'
              failed:
              C:\bea\wlserver6.1\config\cleanoffer\applications\.wlnotdelete\WEB-INF\_tmp_
              war_CleanOffer Server_CleanOffer Server_test\jsp_servlet\__test.java:104:
              setShort(short) in test.Test cannot be applied to ()
              probably occurred due to an error in /test.jsp line 7:
              <jsp:setProperty name="test" property="*" />
              C:\bea\wlserver6.1\config\cleanoffer\applications\.wlnotdelete\WEB-INF\_tmp_
              war_CleanOffer Server_CleanOffer Server_test\jsp_servlet\__test.java uses or
              overrides a deprecated API.
              Full compiler error(s):
              C:\bea\wlserver6.1\config\cleanoffer\applications\.wlnotdelete\WEB-INF\_tmp_
              war_CleanOffer Server_CleanOffer Server_test\jsp_servlet\__test.java:104:
              setShort(short) in test.Test cannot be applied to (<null>)
              test.setShort(null); //[ /test.jsp; Line: 7]
              ^
              Note:
              C:\bea\wlserver6.1\config\cleanoffer\applications\.wlnotdelete\WEB-INF\_tmp_
              war_CleanOffer Server_CleanOffer Server_test\jsp_servlet\__test.java uses or
              overrides a deprecated API.
              Note: Recompile with -deprecation for details.
              1 error
              Fri Nov 09 00:24:58 PST 2001
              [test.war]
              

    It looks like a bug in JSP generator. If you look and the .java
              created by 6.1 it doesn't make any sence:
              String _propertyValue = request.getParameter("short");
              if (_propertyValue != null && !_propertyValue.equals(""))
              test.setShort(null);
              (needless to say that this works correctly in Resin).
              John Hampton <[email protected]> wrote:
              > Thanks for reply,
              > Changing getShort and setShort to getId and setId makes no difference. I
              > still get the error described below:
              > C:\bea\wlserver6.1\config\cleanoffer\applications\.wlnotdelete\WEB-INF\_tmp_
              > war_CleanOffer Server_CleanOffer Server_test\jsp_servlet\__test.java:104:
              > setId(short) in test.Test cannot be applied to (<null>)
              > test.setId(null); //[ /test.jsp; Line: 7]
              > John
              > "Jignesh" <[email protected]> wrote in message
              > news:[email protected]...
              >>
              >> hi,
              >> i think you have not given the property name properly.
              >> give some other name than short becuase short is the keyword (data-type)in
              > java.
              >> bye,
              >> Jignesh
              >>
              >>
              >> "John Hampton" <[email protected]> wrote:
              >> >Hi,
              >> >
              >> >Setting bean properties doesn't work with properties that are of type
              >> >short.
              >> >Any ideas what's going on? I'm using WLS 6.1SP1 on W2K.
              >> >
              >> >--John
              >> >
              >> ><jsp:useBean id="test" scope="session" class="test.Test" />
              >> ><jsp:setProperty name="test" property="*" />
              >> >
              >> >-- Test.java
              >> >package test;
              >> >
              >> >/**
              >> > *
              >> > * @author john
              >> > */
              >> >public class Test {
              >> >
              >> > /** Creates new Test */
              >> > public Test() {
              >> > }
              >> >
              >> > public short getShort() {
              >> > return 0;
              >> > }
              >> >
              >> > public void setShort(short val) {
              >> > }
              >> >}
              >> >
              >> >Produces the following error while attempting to compile the jsp:
              >> >
              >> >Compilation of
              >>
              >>'C:\bea\wlserver6.1\config\cleanoffer\applications\.wlnotdelete\WEB-INF\_tm
              > p
              >> >warCleanOffer Server_CleanOffer Server_test\jsp_servlet\__test.java'
              >> >failed:
              >>
              >>---------------------------------------------------------------------------
              > -
              >> >----
              >>
              >>C:\bea\wlserver6.1\config\cleanoffer\applications\.wlnotdelete\WEB-INF\_tmp
              > _
              >> >war_CleanOffer Server_CleanOffer Server_test\jsp_servlet\__test.java:104:
              >> >setShort(short) in test.Test cannot be applied to ()
              >> >probably occurred due to an error in /test.jsp line 7:
              >> ><jsp:setProperty name="test" property="*" />
              >> >
              >>
              >>C:\bea\wlserver6.1\config\cleanoffer\applications\.wlnotdelete\WEB-INF\_tmp
              > _
              >> >war_CleanOffer Server_CleanOffer Server_test\jsp_servlet\__test.java
              >> >uses or
              >> >overrides a deprecated API.
              >> >
              >>
              >>---------------------------------------------------------------------------
              > -
              >> >----
              >> >Full compiler error(s):
              >>
              >>C:\bea\wlserver6.1\config\cleanoffer\applications\.wlnotdelete\WEB-INF\_tmp
              > _
              >> >war_CleanOffer Server_CleanOffer Server_test\jsp_servlet\__test.java:104:
              >> >setShort(short) in test.Test cannot be applied to (<null>)
              >> > test.setShort(null); //[ /test.jsp; Line: 7]
              >> > ^
              >> >Note:
              >>
              >>C:\bea\wlserver6.1\config\cleanoffer\applications\.wlnotdelete\WEB-INF\_tmp
              > _
              >> >war_CleanOffer Server_CleanOffer Server_test\jsp_servlet\__test.java
              >> >uses or
              >> >overrides a deprecated API.
              >> >Note: Recompile with -deprecation for details.
              >> >1 error
              >> >
              >> >
              >>
              >>---------------------------------------------------------------------------
              > -
              >> >----
              >> >Fri Nov 09 00:24:58 PST 2001
              >> >
              >> >
              >> >
              >> >
              >> >begin 666 test.war
              >> >M4$L#!!0`" `(`,@`:2L````````````````4``0`345402U)3D8O34%.249%
              >> >M4U0N34;^R@``X^4"`%!+!PBLA:(4! ````(```!02P,$% `(``@`R !I*P``
              >> >M``````````````\```!714(M24Y&+W=E8BYX;6RE4DMOVS ,/L^ _P/GTP9,
              >> >M4NH=M@YIBC3I@ )M&G3IAIX*1V9B!;)D6'0>WY2GDT6# /FD&1WX,4V]?+
              >> >M4L,<:Z>LN4HN>"L!--+FRDRODN?1=_8UN>[$4?L]8W$$)]^/QL"P&6LEX5Y)
              >> >M- YA8,G_Q5$<C0H$:0VA(0=V`E0H!Q.E$;(:P37C&4H"LKZ 9Y3BZ.<F%?A0
              >> >M\"$T)=M2\I'#BVV@S%9@+$'C?0_JN)18$2@31]*6E5:9D0@+1<7:::O!H>O3
              >> >M5:M-LCT,7B6;9TIGXQ"4XJ@@JKX)L5@LN&L,]Y)B-]UCK:;*9!IZ-E\S!T@W
              >> >MF!G'(93OC"+EJWV<H[85UCNO'2^.=L0P_H.2M74K1UBZ3YXL.0QM37X#SAM4
              >> >M*T\J""XN+[^PM-5J!4X<G2%UM8:GT.O@"1W6<\QY'#'6";'#2_8?>Z.7X2TL
              >> >M<,RRJMH\Z_#YYOZN!PD3XGP8(?JC/OS",70KOU29A620\E2(VT&R$4FVRYKY
              >> >M%>ZW-4L114ZY$UO#U_0UY1Y(UHG:6[2SD6@[=.'5F3^=B9IV#D>WKY JT3;4
              >> >M.;['SZTWK>)\[P$_4O<1M$^*+-P/T\J%_G='Z(F9,CDN^<Q5;SU/^O]!H*!2
              >> >M_[?"7P3^!'?3M<5A[;\!4$L'"/]33>'A`0``! 0``%!+`P04``@`" #(`&DK
              >> >M````````````````" ```'1E<W0N:G-P-4X[#L(P#-US"A.I"P/>D1LAQ,14
              >> >MB5X@M!84M4E4&XG>GJ:!R<_OIT?5*?D'0Q>#<M!V25Q;Y8_B4Z?15LY0!OFP
              >> >M[QWIH".[ZZV!9HT1EI]P4PW=8[\X8^@EZ?@6/K,/,/2Y4=2"=#'7"XL,,5CH
              >> >M1B]2Q$.[.="5K+ V\VJ>=8'@)_XW0/JQM=T7=W+F$@/O=H9PQ81E`F&9_050
              >> >M2P<(E)0WZYL```#@````4$L#!!0`" `(`,@`:2L````````````````?````
              >> >M5T5"+4E.1B]C;&%S<V5S+W1E<W0O5&5S="YC;&%S<TV/OT[#,!#&OTO2IDT+
              >> >M_4.I6-D*`C(@)A +$E,$0ZKN3K!:5R&1$K=/Q<*$Q, #\%"(LQ-%]7!W_MU]
              >> >MW]F_?]\_<'&-><#IQ,?,QRFA^Z!RI1\)[N)B1?">BC=)&$4JER^[]T262Y%D
              >> >M3*91D8IL)4IE[@WT]$95A$&D9:7#)8=[0F\M=;PI2FT]8P95"[Q%;+:X>Y$1
              >> >MB'M!7.S*5#XK8]<W#C=;L1=#>.@P:'T)8\/#3.3K\#79RE3C' [_Q!P79 0<
              >> >MNWR[Y4R<.Y=?H$\N'/@<`\[ F <GZ'$UK(?0YPZX'EAB#*X:`\?]:-5=2V8'
              >> >M2J=5'N&X4=Y9CL.UM?#,"N=ULQ&::L0/,LLF=G[Z#U!+!PA>>AD-#@$``*4!
              >> >M``!02P$"% `4``@`" #(`&DKK(6B% 0````"````% `$````````````````
              >> >M````345402U)3D8O34%.249%4U0N34;^R@``4$L!`A0`% `(``@`R !I*_]3
              >> >M3>'A`0``! 0```\`````````````````2@```%=%0BU)3D8O=V5B+GAM;%!+
              >> >M`0(4`!0`" `(`,@`:2N4E#?KFP```. ````(`````````````````&@"``!T
              >> >M97-T+FIS<%!+`0(4`!0`" `(`,@`:2M>>AD-#@$``*4!```?````````````
              >> >M`````#D#``!714(M24Y&+V-L87-S97,O=&5S="]497-T+F-L87-S4$L%!@``
              >> >0```$``0`!@$``)0$````````
              >> >`
              >> >end
              >> >
              >>
              Dimitri
              

  • Modify Collection with jsp:setproperty

    Hello:
    I have a problem with jsp and struts.
    I have a collection of items (List) and view the elments in jsp page. This It works fine.
    But the problem happens when i like modify the collection.
    The code to view the collection in jsp is:
    <jsp:useBean id="ItemListForm" class="com.myapp.struts.ItemListForm" scope="session" />
    <html:form action="/ItemEditAction" >
    <logic:iterate name="ItemListForm" property="listaItems" id="item" >
    <P>
    <BASEFONT SIZE="3">
    <jsp:getProperty name="item" property="etiqueta" />
    </BASEFONT>
    <P>
    <jsp:getProperty name="item" property="grafico"/>
    <P>
    </logic:iterate>
    <P>
    <html:submit>Save File</html:submit>
    <html:hidden property="do" value="saveXML"/>
    </html:form>
    The question is:
    How to modify the element "grafico" with jsp:setproperty.
    Thanks for all.

    Thank you, I had forgotten the set part, but then the next problem occurs:
    <jsp:setProperty name="date" property="locale" value="${locales.locale}"/>
    generates:
    org.apache.jasper.JasperException: Unable to convert string '${locales.locale}' to class java.util.Locale for attribute locale: java.lang.IllegalArgumentException: Property Editor not registered with the PropertyEditorManager
    could I only use Strings as input?

  • Need Help:  Problem with JSP setProperty to Bean

    Hi,
    This is my first time posting to this forum so I am not completely aware how Duke dollars work but if anybody can help me I will be happy to give some... whats normal for solving a problem?? 10??
    Anyway... the problem...
    I have a simple JSP with a simple HTML <form> that has a text field and a Submit button. Submit takes the user to the next JSP page however the setter method for property 'user' is never called. I can verify this through an attached debugger.
    I am using Tomcat 5.5, and I never had a problem like this in previous versions of Tomcat.
    I have tried changing the scope of the bean to request however nothing changed. I excluded all my business logic and tested this one more time just to make sure I wasn't inadvertadely screwing with something however this still does not work.
    I am sure I am missing something small but for the life of me I can't figure out what.
    Here is my code:
    index.jsp
    <%@page contentType="text/html"%>
    <%@page 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>JSP Page</title>
        </head>
        <body>
            <jsp:useBean id="something" scope="session" class="com.db.servlet.UserBean">
                <jsp:setProperty name="something" property="*"/>
            </jsp:useBean>
            <p>Select</p>
            <form id="Form1" method="post" action="multi.jsp">
                <p>User: </p>
                <input type="text" name="user" size="20"><br>
                <input type="submit" value="Submit">
            </form>
        <br><p>Or select Single mode.</P><br>
        <a href="tris.html">tris</a>
        </body>
    </html>UserBean:
    package com.db.servlet;
    public class UserBean {
        private String user = null;
        public UserBean() {
        public void setUser(String user) {
            this.user = user;
        public String getUser() {
            return user;
    }

    Oops!
    I not only realized my mistake, I also accidentally posted this in the wrong forum. I meant to post in the JSP Forum.
    For reference, what I did wrong was I placed my setProperty tag in index.jsp rather than placing it in multi.jsp (the file specified in the form action).
    Everything works now.

  • Throwing Exceptions _Through_ jsp:setProperty

    Is it possible to have a setXxxxx method explicitly throw an exception and have it caught by an isErrorPage using the <jsp:setProperty/> tag?
    I'm trying to do this:
    In mypage.jsp
    <%@ page errorPage="myerr.jsp" %>
    <jsp:useBean id="myBean" class="MyBean" ... />
    <jsp:setProperty name="myBean" property="name" value="value"/>
    In MyBean.java
    public void setName(String name) throws MyException
    throw new MyException("Something went wrong");
    In myerr.jsp
    <%@ page isErrorPage="true" %>
    <% exception.printStackTrace(new PrintWriter(out)); %>
    If I run this, it reports an org.apache.jasper.JasperException with a null message on the line number of the setProperty tag.
    If I change jsp:setProperty to <% myBean.setName("value"); %> then the MyException is reported with the right message.
    Any thoughts? I'm running jakarta-tomcat-3.2.1 under i386 Solaris.

    You should use Java code like:
    MyException ex=new MyException("Error!");
    request.setAttribute ( PageContext.EXCEPTION, ex );Can it be done without having to pass the Bean the
    request object?
    I'd like it to work transparently through
    <jsp:setProperty/> without the page coder having to do
    anything extra.You should create your own bean and access to it using
    <jsp:setProperty scope="request">
    place code in your bean...
    Paul

  • How does jsp:setProperty .... property="*" .. work?

    [sorry for my bad english]
    I've seen a convenient way to automatically set javaBean properties from request which look like this. <jsp:setProperty .... property="*"..> I wonder that how does it work? How it understand which set method it should call, for example method setName() for request.getParameter("name"). Could someone give me explanations or link to any related document. Thankyou very much.

    Following Java Beans conventions, the property is managed with methods getXXXX, setXXXX or isXXXX (for boolean properties) using the property name, like in getName() and setName() for example.

  • Jsp:setProperty tag is not working

    hi i am working on project online test system when registering the student i want to use the setProperty tag to set the values from the student form into the approproate bean properties but this tag doesn't work instead i have to set all values of bean by calling the respective setter methods and i am using tomcat as web server.
    i am sending the code as well please help me if u can.
    the html coding for student form is
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>registration of student</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body bgcolor="#677E7E" text="#AC9E6C">
    <table width="75%" border="1" align="center" bordercolor="#677E7E">
    <tr>
    <td><font size="5">STUDENT REGISTRATION FORM</font></td>
    </tr>
    </table>
    <hr>
    <p> </p>
    <form name="student_registration_form" method="post" >
    <script language="JavaScript" >
    function validateField()
              var
                   sos=document.student_registration_form.StartOfSession.selectedIndex,
                   eos=document.student_registration_form.EndOfSession.selectedIndex,
                   deg=document.student_registration_form.Degree.selectedIndex,
                   sem=document.student_registration_form.Smester.selectedIndex,
                   sec=document.student_registration_form.Section.selectedIndex,
                   rol=document.student_registration_form.RollNo.value,
                   pas=document.student_registration_form.Password.value;
    if(sos==0)
                        alert(" \n You Can Not Leave StartOfSession Field Empty");
    else
              if(eos==0)
                        alert("\n You Can Not Leave EndOfSession Field Empty");
              else
              if(deg==0)
                        alert("\n You Can Not Leave Degree Field Empty");
              else
              if(sem==0)
                        alert("\n You Can Not Leave Smester Field Empty");
              else
              if(sec==0)
                        alert("\n You Can Not Leave Section Field Empty");
              else
              if(rol=="")
                        alert("\n You Can Not Leave RollNo Field Empty");          
              else
              if(pas=="")
                        alert("\n You Can Not Leave Password Field Empty");          
              //document.student_registration_form.EndOfSession.value=="" || document.student_registration_form.Degree.value=="" || document.student_registration_form.Section.value=="" || document.student_registration_form.Smester.value=="" || document.student_registration_form.RollNo.value=="" || document.student_registration_form.Password.value=="")
              else
    if(!(sos==0) || !(eos==0) || !(deg==0) ||
              !(sec==0) || !(Smester==0) ||
              !(document.student_registration_form.RollNo.value=="") ||
              !(document.student_registration_form.Password.value=="")
         //document.forms[0].reset();     
    //checking validity of the password field
    var LengthOfRollNo=pas.length;
                   for(i=0;i++;i<LengthOfRollNo )
                        if(!(pas.subString(i,i++)>0))
                                  alert("please enter numaric value in the password field");
                                  return true;
                   document.student_registration_form.submit();
    self.location='StudentRegistration.jsp';
    //return true;
         student_registration_form.StartOfSession.value="";
    student_registration_form.EndOfSession.value="";
    student_registration_form.Degree.value="";
    student_registration_form.Section.value="";
    student_registration_form.Smester.value="";
    student_registration_form.RollNo.value="";
    </script>
    <table width="76%" border="1" align="center" bordercolor="#677E7E">
    <tr>
    <td width="61%"><font size="3">SESSION</font></td>
    <td width="39%">
    <table width="75%" border="1" bordercolor="#677E7E">
    <tr>
    <td><select name="StartOfSession" size="1">
    <option>Start of Session</option>
    <option>2000</option>
    <option>2001</option>
    <option>2002</option>
    <option>2003</option>
    <option>2004</option>
    <option>2005</option>
    <option>2006</option>
    <option>2007</option>
    </select></td>
    <td bordercolor="#677E7E">TO</td>
    <td><select name="EndOfSession" size="1">
    <option>End Of Session</option>
    <option>2001</option>
    <option>2002</option>
    <option>2003</option>
    <option>2004</option>
    <option>20006</option>
    <option>2007</option>
    <option>2008</option>
    <option>2009</option>
    <option>2010</option>
    <option>2011</option>
    <option>2012</option>
    <option>2013</option>
    <option>2014</option>
    </select></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td><font size="3">NAME OF DEGREE</font></td>
    <td><select name="Degree" size="1">
    <option>  </option>
              <option>MCS</option>
    <option>BCS</option>
    <option>BBA</option>
    <option>MBA</option>
    <option>MPA</option>
    <option>BSIT</option>
    <option>MSIT</option>
    <option>BBIT</option>
    <option>MSIT</option>
    </select></td>
    </tr>
    <tr>
    <td>SEMESTER </td>
    <td><select name="Smester" size="1">
    <option>   </option>
              <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
    <option>6</option>
    <option>7</option>
    <option>8</option>
    <option>9</option>
    <option>10</option>
    <option>11</option>
    <option>12</option>
    </select></td>
    </tr>
    <tr>
    <td>SECTION</td>
    <td><select name="Section" size="1">
    <option>   </option>
              <option>A</option>
    <option>B</option>
    <option>C</option>
    <option>D</option>
    </select></td>
    </tr>
    <tr>
    <td>ROLL NUMBER (<font size="2">NUMARIC ONLY</font>)</td>
    <td><input type="text" name="RollNo"></td>
    </tr>
    <tr>
    <td>PASSWORD</td>
    <td><input type="password" name="Password"></td>
    </tr>
    </table>
    <table width="12%" border="1" align="center" bordercolor="#677E7E">
    <tr>
    <td><input type="button" name="Submit_bt" value="Submit" onClick="validateField()" /></td>
    </tr>
    </table>
    <p> </p>
    </form>
    <p> </p>
    </body>
    </html>
    and the bean is
    import java.sql.*;
    public class StudentBean
    private String StartOfSession="",EndOfSession="",Degree="",Section="",Smester="",RollNo="",Password="",Status="",LogIn="";
    Connection cn;
    Statement stmt;
    ResultSet rs;
    public StudentBean()
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
    cn=DriverManager.getConnection("jdbc:odbc:intery");
    stmt=cn.createStatement();
    catch(ClassNotFoundException exp)
         System.out.println("class not found while obtaining connection from StudentBean.java");
                   catch(SQLException exp)
                        System.out.println("SQLException araised while obtaining a connection from StudentBean.java");
                   catch(Exception exp)
    System.out.println("exception in obtaining connection from StudentBean.java");
    public String getStartOfSession()
    return StartOfSession;
    public void setStartOfSession(String startofsession)
    StartOfSession=startofsession;
    public String getEndOfSession()
    return EndOfSession;
    public void setEndOfSession(String endofsession)
    EndOfSession=endofsession;
    public String getDegree()
    return Degree;
    public void setDegree(String degree)
    Degree=degree;
    System.out.println("Degree = "+Degree);
    public String getSection()
    return Section;
    public void setSection(String section)
    Section=section;
    public String getSmester()
    return Smester;
    public void setSmester(String smester)
    Smester=smester;
    System.out.println("yar Smesterrrrrr"+Smester+" from StudentBean");
    public String getRollNo()
    return RollNo;
    public void setRollNo(String rollno)
    RollNo=rollno;
    public String getPassword()
    return Password;
    public void setPassword(String password)
    Password=password;
    public String getStatus()
    return Status;
    public void setStatus(String status)
    Status=status;
    public String isRegistered()
    String IsRegistered="";
    LogIn=StartOfSession.concat("-").concat(EndOfSession).concat("-").concat(Degree).concat("-").concat(Section).concat("-").concat(Smester).concat("-").concat(RollNo);
    try
    PreparedStatement ps=cn.prepareStatement("select * from student where username = '"+LogIn+"'");
    rs=ps.executeQuery();
    if(rs.next())
    IsRegistered="registered";
    else
    IsRegistered="notregistered";
    catch(Exception exp)
    IsRegistered="Exception";
    System.out.println(exp+"from isRegistered method of StudentBean.java ");
    return IsRegistered;
    public boolean checkRollNo()
    try
    //rn is used to keep the value of RollNo
    int rn=Integer.parseInt(RollNo);
    catch(Exception exp)
    return false;
    return true;
    public boolean registerStudent()
                   System.out.println("rigisterStudentMethod has been called");
                        LogIn=StartOfSession.concat("-").concat(EndOfSession).concat("-").concat(Degree).concat("-").concat(Section).concat("-").concat(Smester).concat("-").concat(RollNo);
              System.out.println(LogIn);
                   try
              PreparedStatement ps=cn.prepareStatement("insert into student values(?,?,?)");
              ps.setString(1,LogIn);
              ps.setString(2,Password);
              ps.setString(3,"allowed");
              ps.executeUpdate();
              catch(SQLException exp)
    System.out.println(exp+"from StudentBean.java");
    catch(Exception exp)
    System.out.println(exp+"from StudentBean.java");
                                  System.out.println("Exception during insertion of record in student table from StudentBean.java");
                                  return false;
    return true;
    and the jsp page for seting bean property and performing other actions is
    <jsp:useBean id="StudBean" scope="page" class="StudentBean" />
    \\(here <jsp:setPropety name="StudBean" property="*" /> is not working)
    <%
    StudBean.setStartOfSession(request.getParameter("StartOfSession"));
              StudBean.setEndOfSession(request.getParameter("EndOfSession"));
    StudBean.setDegree(request.getParameter("Degree"));
    StudBean.setSmester(request.getParameter("Smester"));
    StudBean.setSection(request.getParameter("Section"));
    StudBean.setRollNo(request.getParameter("RollNo"));
    StudBean.setPassword(request.getParameter("Password"));
    if(StudBean.checkRollNo()==false)
    %>
    <%@ include file="invalid_data_in_rollno_field.htm" %>
    <%
    else
    String IsRegistered=StudBean.isRegistered();
    if(IsRegistered.equals("registered"))
    %>
    <%@ include file="already_registered.htm" %>
    <%
    else
    if (StudBean.registerStudent() && IsRegistered.equals("notregistered") )
    %>
    <%@ include file="successfull_registration.htm" %>
    <%
    else
    %>
    <%@ include file="unsuccessfull_registration_of_student.htm" %>
    <%
    %>
    please tell me where i am making mistake since i have mentioned all the
    form attributes name and the bean attributes name as same.

    I think that all your form parameters must begin with alowercase letters, for example
    startOfSession instead of StartOfSession
    try to rename your selectname paramters.
    Le me know if ti works,
    Giovanni

Maybe you are looking for