Pass bean property name across JSP pages

First, the sample code:
<%-- ================ some.jsp =============== --%>
<%-- bunch of code [...] --%>
<tr>
<td><bean:message key="prompt.desc" /></td>
<td><html:textarea property="desc" /></td>
</tr>
<tr>
<td>
<bean:message key="prompt.notes" />
<tiles:insert page="checkSpellTile.jsp" flush="false"></tiles:insert>
</td>
</tr>
<tr>
<td><html:textarea property="notes" /></td>
</tr>
<%-- ================ end some.jsp =============== --%>
<%-- ================ checkSpellTile.jsp =============== --%>
<%-- some JSP code [...] --%>
<spellingComp:executeSpelling
mode="popup"
textComponentName="notes"
/>
<%-- ================ end checkSpellTile.jsp =============== --%>
So, my first foray into JSP programming - I have a number of
different JSP pages that need spell check widgets associated
to some text fields. The sample code shown works fine. The
prompt, "Notes ...:" is following by the spell check
[clickable] widget. Then the user clicks the widget, the
spell check is launched and it checks the text in the
"notes" field for the form.
The sticky situation that I can't seem to solve is that each
of the forms associated with each of the different JSP pages
has a different name for the text field (that needs to be
spell checked).
I've tried doing this (between the <tiles:insert...></tiles:insert...>):
<tiles:put name="theNotes" beanName="orderForm" beanProperty="notes"/>
... and then in the checkSpellTile.jsp, inserting this:
<tiles:importAttribute name="theNotes"/>
... and then for the "textComponentName" attribute:
textComponentName="theNotes"
Any ideas how do solve this problem?

First, the sample code:
<%-- ================ some.jsp =============== --%>
<%-- bunch of code [...] --%>
<tr>
<td><bean:message key="prompt.desc" /></td>
<td><html:textarea property="desc" /></td>
</tr>
<tr>
<td>
<bean:message key="prompt.notes" />
<tiles:insert page="checkSpellTile.jsp" flush="false"></tiles:insert>
</td>
</tr>
<tr>
<td><html:textarea property="notes" /></td>
</tr>
<%-- ================ end some.jsp =============== --%>
<%-- ================ checkSpellTile.jsp =============== --%>
<%-- some JSP code [...] --%>
<spellingComp:executeSpelling
mode="popup"
textComponentName="notes"
/>
<%-- ================ end checkSpellTile.jsp =============== --%>
So, my first foray into JSP programming - I have a number of
different JSP pages that need spell check widgets associated
to some text fields. The sample code shown works fine. The
prompt, "Notes ...:" is following by the spell check
[clickable] widget. Then the user clicks the widget, the
spell check is launched and it checks the text in the
"notes" field for the form.
The sticky situation that I can't seem to solve is that each
of the forms associated with each of the different JSP pages
has a different name for the text field (that needs to be
spell checked).
I've tried doing this (between the <tiles:insert...></tiles:insert...>):
<tiles:put name="theNotes" beanName="orderForm" beanProperty="notes"/>
... and then in the checkSpellTile.jsp, inserting this:
<tiles:importAttribute name="theNotes"/>
... and then for the "textComponentName" attribute:
textComponentName="theNotes"
Any ideas how do solve this problem?

Similar Messages

  • How does session bean contain in the JSP page

    May i know how session bean contains in the JSP page
    If the situation is like the following ...
    if i dont want to put the session bean in the session
    like this :
    session.setAttribute("UserBean",userBean);
    the way i get the session bean is only
    session.getAttribute("UserBean");
    Does have the other way to get the Session bean during the JSP
    if i dont want to use this kind of way,
    what else i can do for?
    may i know the solution with detailed
    and please attach the solution of code to me if you know...
    thanks...

    Hi,
    I am not clear with ur query..
    What I understood from ur query is that, u are trying to put the session ejb in the HttpSession Object for some use ahead in future?
    If this is the case, then I think are approach is not correct.
    StatefulSession beans are meant for this purpose, i.e they will be maintaining the client session. So use the same using the JndiLookup of the HomeInterface and the getting the Home reference and calling the businessmethods
    sameer

  • Bean Value display in JSP Page

    Hi,
    I am trying to display a value stored in my bean on the jsp page. The value is to be displayed on the initial jsp page.
       public void doInitialization()
              request = (IPortalComponentRequest) this.getRequest();
              response = (IPortalComponentResponse) this.getResponse();
              myContext = request.getComponentContext();
              myProfile = myContext.getProfile();      
              Statement += "doInitialization";
              BeanContainer = new MockUpBean();
              BeanContainer.setValues( Statement);
              myProfile.putValue( "myBean", BeanContainer);
              // reset String
              BeanContainer = ( MockUpBean) myProfile.getValue( "myBean");     
        }// public void doInitialization()
    On the JSP Page side:
    <jsp:useBean id="myBean" scope="application" class="MockUpBeanPackage.MockUpBean" />
    <%= myBean.getValues()%>
    The jsp page does no pick up the value I try to store in the doInitialise method.
    Any thoughts on what I may have done wrong in my code.
    I try response.write("Test"), this too does not show up in my JSP page.
    Any advice would be appreciated.
    Thank you
    NAC

    Marty,
    The portalapp.xml file is as follows:
    <?xml version="1.0" encoding="utf-8"?>
    <application>
      <application-config>
        <property name="PrivateSharingReference" value="com.sap.portal.htmlb"/>
      </application-config>
      <components>
        <component name="MockUpPage">
          <component-config>
            <property name="ClassName" value="MockUpPackage.MockUpPage"/>
            <property name="SecurityZone" value="MockUpPackage/low_safety"/>       
            <property name="ComponentType" value="jspnative"/>
            <property name="JSP" value="pagelet/InitialPage.jsp"/>
          </component-config>
          <component-profile>
            <property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
          </component-profile>
        </component>
      </components>
      <services/>
    </application>
    Again any help would be apreciated. I have used this piece of code to write values to beans in various projects, never had any issues. This is the first time I am having an issue with this piece of code.
    NAC

  • Bean not found by JSP page

    Hi! All
    I am using a bean in my jsp page. When I open the jsp page, I get an error that "Class SQLBean.DbBean not found". Please help. I have my bean class compiled and saved under C:\tomcat\webapps\examples\WEB-INF\classes
    Here is the bean class:
    package SQLBean;
    import java.sql.*;
    import java.io.*;
    public class DbBean {
    String dbURL = "jdbc:db2:sample";
    String dbDriver = "jdbc:odbc:akhil.mdb";
    private Connection dbCon;
    public Class DbBean(){
    super();
    public boolean connect(String user, String password) throws ClassNotFoundException,SQLException{
    System.out.print("hey");
    Class.forName(dbDriver);
    dbCon = DriverManager.getConnection(dbURL, user, password);
    return true;
    public void close() throws SQLException{
    dbCon.close();
    public ResultSet execSQL(String sql) throws SQLException{
    Statement s = dbCon.createStatement();
    ResultSet r = s.executeQuery(sql);
    return (r == null) ? null : r;
    public int updateSQL(String sql) throws SQLException{
    Statement s = dbCon.createStatement();
    int r = s.executeUpdate(sql);
    return (r == 0) ? 0 : r;
    Here is the jsp page:
    <HTML>
    <HEAD><TITLE>DataBase Search</TITLE></HEAD>
    <BODY>
    <%@ page language="Java" import="java.sql.*" %>
    <jsp:useBean id="db" scope="request" class="SQLBean.DbBean" />
    <jsp:setProperty name="db" property="*" />
    <%!
    ResultSet rs = null ;
    ResultSetMetaData rsmd = null ;
    int numColumns ;
    int i;
    %>
    <center>
    <h2> Results from here</h2>
    <hr>
    <br><br>
    <%
    out.print("Here");
    db.connect("atayal", "arduous");
    try {
    out.print("HI");
    rs = db.execSQL("select * from contacts");
    }catch(SQLException e) {
    throw new ServletException("Your query is not working", e);
    %>
    <%
    while(rs.next()) {
    %>
    <%= rs.getString("email") %>
    <BR>
    <%
    %>
    <BR>
    <%
    db.close();
    %>
    Done
    </body>
    </HTML>
    Thanks in advance

    Thank you for your valuable feedback duffymo. Could
    you explain a little what you mean by "Putting .class
    files in the Tomcat examples directory is a really bad
    idea in the long run". Also, could you direct me to
    some source where I can find more information on
    creating WAR files keeping in mind that I am a
    beginner.
    Thanks.But putting your web apps into WAR files, you can have quite a few different web apps running on the tomcat server as compared to if u place your files into the default webapp folder, u can only have 1 web app running.
    For creating WAR file, the easiest way is to use an IDE like JBuilder.

  • Checking Value passed by Checkbox in a jsp page ??

    hi all,
    in my jsp page, i've a checkbox on a page & after submitting that page to another one, i want to check whether the checkbox was clicked or not..since in my code i wanna something like this...
    if checkbox is clicked
    //task1
    else
    {//task2
    Can anyone please help me how to go 'bout it !

    Hi ! romit
    As the solns suggested above r correcti just wanna add another thing of ur interest ie when the checkbox is checked ,the url contains the thecked checkbox name equals "on"...i hope u understood what i meant...
    ie
    <input type=checkbox name="checkIt">
    now in url...it will be like....
    http://localhost/...../..... ..?...&check=on&.....
    in case the checkbox is checked...else null value is passed....

  • Carrying values across jsp pages

    hi there!
    i got a quick question...
    ive got a login page where users enter their email address and a password and upon pressing the submit button the login page calls the page processlogin.jsp which verifies this email addres and password with those values stored in the database.
    a successful login then displays another page where users submit other details. this form then calls another process jsp page which stores this new information in another table in the database.
    my question is how do i 'pass' through that initial email address the user enters on the login page through to this latter page....and inevitably...on to other pages too.
    the reason i need to do this is cos the table which i am storing these new details has email address as its foreign key and i need to store the same value.
    many thanks! :o)

    the simplest thing to do is create a bean to hold on to values a user enters and simply have access to them using the <%= bean.getEMAIL() %> or something like that. For multiple form pages, I like using <input type=hidden ...> to store values without having to create object to store them.
    But I think in your case, since you have a processing page for the form before it goes on then the bean is the best solution.
    Good luck

  • Maintaining Transactions Across JSP Pages

    Hi,
    I have a multi page Registration (3 steps). On each step data submitted is taken
    to the database via an EJB component (Session Bean). How do I maintain a transaction
    across these JSP pages (i.e. either in the EJB or in the jsp) so that the data
    in the database is consistent? So if there is a problem in the 3rd step the data
    submitted in the first two steps should be rolled back.
    Can I use a statefull session beans, which will maintain a database connection
    created during the first step, so that I can use the same connection for steps
    2 & 3. In the first step after getting the database connection I will begin a
    transaction and insert the first part of the data, then this connection will be
    maintained by the statefull session and used for steps 2 & 3. At the end I will
    commit the transaction. Will this work?
    How do I maintain transaction across multiple pages? Is there is any standards
    for this scenario where the transaction is maintained across multiple pages. I
    cannot carry data across the jsp pages because of the complex data collected.
    Any help appreciated.
    Regards
    -MohanRaj

    You can not and should not do it the way that you are proposing. Keeping a transaction
    open across any interaction with the user is a big mistake. Transactions are scarce
    resources. They need to be short. You will need to collect the data from the three
    pages in the servlet itself. You can use the HTTPSession, or hidden fields in
    the forms. Only after all of the data is collected should you begin a transaction
    and update the database. Alternatively, you could store the partial data in a
    temporary database table, and move it to a permanent table when all of the data
    has been provided.

  • Passing value from JApplet to Jsp page

    Hello,
    How can i pass a value that is entered in a JTextArea in a JApplet and fetch the entered value from JTextArea and display it in a JSP page.
    It would be kindful if someone could help me with this problem.
    Regards
    Sanam

    hello,
    Thanks for ur reply,
    Sorry to say that i did not understand where to implement ur code in my code.
    Below is my code could u plz tell me where do i put in ur code.
    My code works fine u can compile it.
    javac *.java;
    appletviewer BIA.java
    Can u plz tell the JSP code.
    It would be very kindful if u could please help me.
    Thank you
    //**************** BIA.java***********
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import java.net.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import java.util.Vector;     
    import java.applet.*;     
    import java.awt.image.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.lang.reflect.Field;
    <applet code = "BIA" width = 500 height = 500>
    </applet>
    public class BIA extends JApplet
         public static Container cp;
         public BIAP panel;     
         public TB action;
         public void init()
              panel = new BIAP();
              action = new TB(panel);
              action.setLayout(new GridLayout(2,2));     
              cp = getContentPane();
              cp.setLayout(new BorderLayout());
              cp.add(action, "North");
              cp.add(new JScrollPane(panel));
              repaint();
    //******************* BIAP.java*************
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import java.net.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import java.util.Vector;     
    import java.applet.*;     
    import java.awt.image.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.lang.reflect.Field;
    class BIAP extends JPanel
         public BIA bia;
         public BufferedImage image;
         public double scale, scaleInc;
         public JTextArea jt;
         public BIAP()
              loadImage();
              setBackground(Color.white);
              scale = 1.0;
              scaleInc = 0.01;
              setLayout(null);
              jt = new JTextArea("Welcome");
              jt.setBounds(0,0, 90,30);
              add(jt);     
              repaint();
         protected void paintComponent(Graphics g)
              super.paintComponent(g);
                   Graphics2D g2 = (Graphics2D)g;
              g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                        RenderingHints.VALUE_INTERPOLATION_BICUBIC);
              int w = getWidth();
              int h = getHeight();
              int imageWidth = image.getWidth();
              int imageHeight = image.getHeight();
              int x = (w - imageWidth)/2;
              int y = (h - imageHeight)/2;
              g2.drawImage(image, x, y, this);
         private void loadImage()
              String fileName = "Terragen___Losing_Grip_by_Blackheart6004.jpg";
              try
              URL url = getClass().getResource(fileName);
              System.out.println(url);
              image = ImageIO.read(url);
              catch(MalformedURLException mue)
              System.out.println("url: " + mue.getMessage());
              catch(IOException ioe)
              System.out.println("read: " + ioe.getMessage());
         public Dimension getPreferredSize()
              Dimension d = new Dimension();
              d.width = (int)(scale * image.getWidth());
              d.height = (int)(scale * image.getHeight());
              return d;
         //method used for Zoom Operation
         public void setScale (int inc)
              scale += inc * scaleInc;
              revalidate();
              repaint();
    //************************** TB*********************
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import java.net.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import java.util.Vector;     
    import java.applet.*;
    import java.awt.image.*;
    import javax.swing.*;
    import javax.swing.event.*;
    class TB extends JPanel
         BIAP panel;
         JButton save = new JButton("Save");
         public TB(BIAP biap)
              panel = biap;
              ActionListener sa = new ActionListener()
                   public void actionPerformed(ActionEvent e)          
                        JButton button = (JButton)e.getSource();
                        if(button == save)
                             //panel.fileSave();
              save.addActionListener(sa);
              add(save);
    }

  • How to add multiple bean id in a jsp page

    i need to add two bean id in a single jsp page can anyone suggest me how can i do that?
    <jsp:useBeanid="newmember" class = "com.assignment.member" scope ="request"/>now if i want to add another bean id in the same jsp page is that possible? how can i do that? please help

    <jsp:useBeanid="newmember" class = "com.assignment.member" scope ="request"/>
    <jsp:useBeanid="newmember2" class = "com.assignment.member2" scope ="request"/>
    <jsp:useBeanid="newmember3" class = "com.assignment.membe3r" scope ="request"/>
    upto N bean

  • Pass Object Between Applet and JSP Page

    Hi all,
    How can I pass an Object(such as Vector, File), rather than just string to the Applet from a JSP page?
    Thank you.

    I used Base64Encoder and Base64Decoder from servlets.com utilities.
    * convert any serializable object to a String
    public synchronized static String objectToString(Serializable obj) throws Exception {
        ByteArrayOutputStream bos = new ByteArrayOutputStream(100);
        ObjectOutputStream oos = new ObjectOutputStream(bos);
        oos.writeObject(obj);
        byte[]bytes = bos.toByteArray();
        bos = new ByteArrayOutputStream(); //to save the encoded String
        Base64Encoder enc = new Base64Encoder(bos);
        enc.write(bytes);
        String encodedString = bos.toString();
        //close all
        enc.close();   
        oos.close();
        bos.close();
        return encodedString;
    * Recreates the object from the encoded String
    public synchronized static Object stringToObject(String str) throws Exception {
        ByteArrayInputStream bis = new ByteArrayInputStream(str.getBytes());
        Base64Decoder dec = new Base64Decoder(bis);
        ObjectInputStream ois = new ObjectInputStream(dec);
        Object obj = (Object)ois.readObject();
        ois.close();
        dec.close();
        bis.close();
        return obj;
    }

  • How to execute a backing-bean method before loading JSP Page?

    Hi everybody.
    Scene:
    An AdfForm, with
    -SelectChoice, referenced to a <list> of pageDef, which is referenced to an ADF BC.
    Goal:
    -Executing the query of the ADF BC before load the SelectChoice, to load the correct values.
    A good question to know:
    Exists any way to execute a method of backing before loading a JSP Page?
    Any similar to onload method of javascript. It could be fantastic.
    Thanks in advance,
    Jaime

    hi Jaime
    If I understand correctly, you are using the ADF Model for data binding.
    Because your goal is "Executing the query of the ADF BC ...", maybe you can also consider to refresh an executable in your Page Definition.
    See also "10.5.5 How to Use Refresh Correctly for InvokeAction and Iterator Bindings"
    at http://download.oracle.com/docs/html/B25947_01/bcdcpal005.htm#BJECHBHF
    It says "... You can use the Refresh property on iterator bindings and invokeAction executables in your page definition to control when each are evaluated during the ADF page lifecycle, either during the prepareModel phase, the prepareRender phase, or both. ...".
    Although you have posted your question in a structured way, which is a good thing, I think it would help to understand your question if you can explain how you determine "the correct values" for your list, what is varying?
    success
    Jan Vervecken

  • Passing jsf parameters to a jsp page

    how to access the parameters declared in jsf page from a jsp page.
    in the jsp page I need to access the paramaters something like request.getParameter("age");
    how to declare the same in the jsf page in h form.
    <h:form>
    <h:inputText value="" id = "age" />
    </h:form>
    and in the jsp page i should access this parameter like request.getParameter("age");
    how to accomplish this.
    Please help.

    Please don't doublepost. Continue here: http://forum.java.sun.com/thread.jspa?threadID=5252759

  • How to retrieve resource name in JSP page

    Hello,
    I have the following scenario:
    User wants a new resource to be provisioned to himself, he makes standard steps; chooses one resource from the list of available resources and sends a request. After that a summary page is displayed - my goal is to create an url to external application on that summary page (i.e. tjspRequestSubmitTiles.jsp) that should be displayed depending on the name of the resource, e.g. if user requests for a ResourceA - link appears, but when he requests for a ResourceB - link does not appear.
    So far I have created a link with a sample if statement - it works.
    My problem is how to make a real condition - retrieve the resource name that request deals with. Anybody know how to do that, which API to use etc.?
    Regards,
    Maciej.

    After adding the code to tjspProvideDataShowInfoTiles.jsp file, nothing has been improved, I am still facing the same result (on the console):
    RO: null
    It seems that file (tjspProvideDataShowInfoTiles.jsp) does not take part in the process.
    I have tried to pass some sample session attribute in tjspRequestVerificationTiles.jsp and this works, but I do not know how to retrieve resourceName in this file.
    I was trying to make some code retrieving resourceName in tjspRequestSubmitTiles.jsp, e.g.
    tcRequestWizardForm tcReqWizForm = (tcRequestWizardForm)session.getAttribute(requestWizardForm);
    String requestID = tcreqWizForm.getRequestID();
    ...and what to do now to retrieve resourceName?

  • Passing an array from one jsp page to another.

    I need to pass an array from one page to another, without using the query string.
    Can anyone help?
    I was given one suggestion about putting the array inside a Map object, then putting the map in the session.
    Is there an alternative? i am struggling to find out how to use maps properly.
    Alternatively, could someone give me a pointer on how to implement this possibility?
    Help needed ASAP.
    Thankyou

    First.jsp
    String[] str = {1,2,3,4,5};
    session = request.getSession(true);
    session.setAttribute("str",str); //or application.setAttribute("str",str);
    Second.jsp
    session = request.getSession();
    String str[] = (String[])session.getAttribute("str"); //or String str[] = (String[]) application.getAttribute("str");
    Now you can use str[].
    Sudha

  • How to pass Bean from servlet to jsp

    I had fetched record from my database to my servlet and passed it to bean.
    how should i pass that bean to my jsp to display the record values in their corresponding textboxes??

    leozeo write: I had fetched record from my database to my servlet and passed it to bean.
    how should i pass that bean to my jsp to display the record values in their corresponding textboxes?? Post the code

Maybe you are looking for