html:link .... Struts

I want a Link as action
MyJsp.jsp
<html:link action="/MyAction?myParam=true">MyText</html:link>
MyAction.java
in der Methode execute (...........)
String Str = request.getParameter("MyParam");
the pProblem I becom the Str null whay ????
thanks

You can't map the action directly to an Action class.
You have to map it via the struts-config.xml with an action like:
<action path="/myAction" type="MyAction"/>
And call this action from the jsp by f.ex.
<% pageContext.setAttribute("MyParam", "Hello"); %>  <!--just adding a parameter -->
<html:link action="/myAction" name="MyParam"/>The name attribute specifies the query string parameter(s).
You should be able to access the parameter now in MyAction with your original execute method.

Similar Messages

  • Html:link not working in struts project driving me mad, please help...

    Afternoon all,
    Can anyone help me with an issue I'm having with my first struts project, I'm learning as I go.
    Anyway, I'm trying to create a bog standard hypertext link which passes a value back to a specified struts action. The flow of the application
    is as follows:
    1) search.jsp
    User enters a name and postcode to search on, then click submit
    2) searchAction
    Struts action 'search' is called and does the search in a back-end db.
    Each result found from search is created as a javabean (named resultsBean), and added to a list object. The list object is set as a request
    attribute named 'SearchResults'.
    The action is then forwarded on to another jsp page named results.jsp
    3) results.jsp
    The results.jsp page retrieves the list object from the 'SearchResults' attribute and loops through each entry
    in the list and converts each entry to the 'resultsBean' javabean object.
    Each resultsBean object has a getVirtualID method which stores a string value. This value is retrieved and a hypertext link is created which
    passes this value on to another struts action named 'select'.
    When this link is clicked on, the select struts action is called and the value passed as a parameter is retrieved.
    This is the part I can't get to work, I can't get the link to render properly. When I click the link the select action retrieves
    & lt;%= resultsBean.getVirtualID() & gt; as the value of the parameter 'vid' instead of the value stored in the getVirtualID method of the resultsBean.
    Listed below is the code from my results.jsp page. If anyone can help me get this to work I would be very grateful.
    Thanks in advance,
    Alex
    results.jsp code
    <%
       List searchResults = (List)portletRequest.getPortletSession().getAttribute("SearchResults");
    %>
    <div id="table_layout" style="width: 713px; margin: 0px 0px 0px 3px;">
      <div id="row">
        <div id="column"><img src='<%= response.encodeURL("/images/results.gif") %>' alt="" width="223" height="159" border="0" /></div>
         <div id="column" style="width: 30px;"></div>
         <div id="column">
          <div id="table_layout" style="width: 460px;">
            <div id="row" style="width: 430px; border-bottom: 1px solid #4e137d;">
              <div id="column" style="width: 155px;">Name</div>
              <div id="column" style="width: 10px;"> </div>
              <div id="column" style="width: 130px;">Address</div>
              <div id="column" style="width: 10px;"> </div>
              <div id="column" align="right" style="width: 120px;">References</div>
            </div>
    <% if (searchResults.size() > 0) {
           Iterator it = searchResults.subList(0, searchResults.size()).iterator();
           ResultsBean resultsBean = new ResultsBean();
           while (it.hasNext()) {
                resultsBean = (ResultsBean)it.next(); %>
            <div id="row" style="padding: 5px 0px 10px 0px;">
              <div id="column" style="width: 155px;"><html:link styleClass="results"  page="/select.do?vid='<%= resultsBean.getVirtualId() %>'" title="<%= resultsBean.getFullName() %>"><%= resultsBean.getFullName() %></html:link></div>
              <div id="column" style="width: 10px;"></div>
              <div id="column" style="width: 130px;"><%= resultsBean.getFullAddress() %></div>
              <div id="column" style="width: 10px;"></div>
              <div id="column" align="right" style="width: 120px;"><%= resultsBean.getReferenceIcons(portletResponse) %></div>
              <div id="column" style="width: 13px;"></div>
              <div id="column" style="width: 22px;"><input id="<%= resultsBean.getVirtualId() %>" name="ckbox" type="checkbox" value="" title="tick to select for merging" style="border: 0px solid #ffffff;"></div>
            </div>
    <%     }
       } %>
           </div>
         </div>
      </div>
    </div>
    <br />
    <br />
    <html:link forward="/searchpage">Return to search page</html:link>

    If you have part of an attribute dynamic, you need to make the entire attribute an expression.
    ie instead of
    page="/select.do?vid='<%= resultsBean.getVirtualId() %>'"
    it has to be
    page="<%= "/select.do?vid=" + resultsBean.getVirtualID() %>"
    However for my approach, I would aim for zero scriptlets, and use the struts tags even more. For instance instead of an iterator, use the struts logic:iterate tag (or the JSTL c:forEach>
    Also instead of div tags, I would use html table tags - <table> <tr><td> etc etc. Thats what its for right?
    Here is at least some of it rewritten with struts tags.
    I left out the div tags so I could focus on the "important" stuff.
    <logic:iterate id="resultsBean" name="SearchResults">
      <html:link styleClass="results"  page="/select.do" paramId="vid" paramName = "resultsBean" paramProperty="virtualId">
        <bean:write name="resultsBean" property="fullName"/>
      </html:link>
      <bean:write name="resultsBean" property="fullAddress"/>
    <%= resultsBean.getReferenceIcons(portletResponse) %>
    <input id="<%= resultsBean.getVirtualId() %>" name="ckbox" type="checkbox" value="" title="tick to select for merging" style="border: 0px solid #ffffff;">
    </logic:iterate>I'm not entirely certain what you are doing with that checkbox at the end. They all have the same name, but no value. You couldn't identify at the server end which one was clicked.
    Hope this helps some,
    evnafets

  • Passing values to action form in struts using html:link tag in struts

    hi
    As we can post values to action form bean in struts using a <html:text> tag in side a form.
    Can the same be achieved by using a html:link attribute.
    If not then how can this be achieved (i.e. posting a form on click of a link and populating action form bean property for the same).
    thanx in advance.

    Crosspost:
    http://forum.java.sun.com/thread.jspa?threadID=5244035&tstart=0

  • html:link problem in struts

    <a href="photo.jsp?cmd=showa&Id=<%=Id)  %> target="thumbs">This is normal coding in jsp. how to use the same coding in struts using <html:link>
    Please Help me.
    Thanks in Advance
    regards
    pooja</a>

    Have a look at this.
    http://struts.apache.org/struts-action/struts-el/tagreference.html#link

  • Struts - HTML:link tag with dynamic page attribute?

    I am trying to use the html:link but the page value is dynamic (resulting from the bean within the iterate tag). The code below doesn't work - error. Is there a way to use all Struts tags and make this happen. Any ideas?
            <logic:iterate id="myMenuForm" property="menuItem" scope="session" name="menuForm" >          <html:link page="<bean:write name="myMenuForm" property="menuDisplayName"/>">                  <bean:write name="myMenuForm" property="menuDisplayName"/>          </html:link>        </logic:iterate> Thanks,
    mlv

    Thanks for all your help. Based on all you your comments, it is now working
    and I thought I would provide some details about how I got it working.
    There are not that many examples within the Struts documentation.
    id = unique name for the object that can be referenced within the iterate
    tag.
    name = is the Bean, in this case it's the ActionForm, that contains the List
    object that will be iterated. In my case, I have a ActionForm that contains
    a List property that contains all the menu item rows from the databse.
    property = is the property name within the ActionForm that is the List
    object. Links to the getter method
    Within the <bean:write> tag you use the id name to get a handle on the final
    object from the iterate tag and the property is one of the property values
    within the bean that is contained within the List.
    So in this case I have a ActionForm bean that contains a List property that
    contains a collection of beans.
    FormAction - bean
    property menuItems of type List contains:
    - row 1 = bean (with a property of menuDisplayName)
    - row 2 = bean (with a property of menuDisplayName)
    - row 3 = bean (with a property of menuDisplayName)
    Here's the JSP code for the tag.
            <logic:iterate id="myMenuForm" name="menuForm" property="menuItem" >
              <html:link page="www.yahoo.com"/>
                      <bean:write name="myMenuForm" property="menuDisplayName"/>
              </html:link>
            </logic:iterate>Now I would like to make the <html:link> page attribute value dynamic from
    the iterate bean. Therefore, you can make the url for the link dynamic If
    you know how to do that, please feel free to provide some help.

  • How to use pdk-struts-html:link

    i have a portlet,
         <pdk-html:link href="/StartEhrpHrj.do?targetGroup=Hrj1030MInfDtlGroup">
                   xyz
    </pdk-html:link> </td>
    but no link,why

    Hi,
    It is not an issue with the tag. Look at the docs for the struts html:link tag; the pdk-html:link tag is intended to replace this tag and not the regular HTML anchor tag.
    Good luck,
    Hernando
    hjbconsulting at comcast dot net

  • Struts html:link

    hi all,
    I am new to struts, but experienced with jsp and serlets.
    I am facing a difficulty using <html:link..............
    what i need is that, i should be able to transfer current page status and data like link clicked to action class which can analyze the page data and make decision there. this will allow me to have same url for multiple purposes, i can do this using <form action="" but similar feature is required in <html:link
    I am really stuck. Need urgent Help.
    Helping me understand the <html:link name="" action="" forward="" may also help
    Thanks in advance....
    Edited by: ksinha on Aug 16, 2010 11:21 PM

    Either that or possibly create a filter in the second app that catches it and forwards it where you want it.

  • Struts tag html:link doesn´t work in Safari

    *Very important question for our company!*
    I´m trying to optimize our web application( www.seb.de) for Safari browser.
    The problem is that Safari don´t display Struts <html:link> on the page. On the page should be a button "delete" at the right side.
    Button Code:
    <html:link>
    href="DeleteMail"
    newFlow="true"
    styleClass="a_delete"
    bundle="<%=SebMailBoxConstants.BUNDLESEBMAIL%>"
    titleKey="Delete"
    </html:link>
    There is a styleClass "a_delete", which this button uses:
    a.a_delete
    background-image: url('icon/icon_delete.gif');
    background-repeat: no-repeat;
    width: 12px;
    padding-right: 12px;
    margin-top: 2px
    Please help me to solve this problem.
    Best regards,
    Sergei.
    SEB Group.

    same thing here, I've talked to apple twice and no resolution
    if you move the screen up you can usually get the links to work
    also when I do Google searches I can get to the second page of results and then I can go no further

  • Problem in html:link tag in struts

    hi every body i have a problem i have to pass two dynamic variable to next page using html:link tag how can i send it
    for example
    <a href = "editEmp.jsp?id=<%= empSno %>&&delete=no"> Edit </a>
    should be coverted into <html:link >and i want to pass 2 parameters to next page how can i do can anybody help

    i have used forward only but how to passs variable dynamically in forward for eaxmpleeee
    i am retreving records from database
    emdID name desig
    1 suresh PM edit
    2 ram PL edit
    when user clecks on link of edit of suresh then i should pass controll to edit page with his empID an parameter............
    i have done this prevoiusly by href tag like
    while (rst.next()) { %>
                        <tr>
                             <% empSno = rst.getInt ("ID");%>
                             <td align = "left"><%= empSno %></td>
                             <td align = "left"><%= rst.getString ("empno") %></td>
                             <td align = "left"><%= rst.getString ("empname") %></td>
                             <td align = "left"><%= rst.getString ("desig") %></td>
                             <td><a href = "strutsEx/ch05/editEmp.jsp?id=<%= empSno %>&&delete=no"> Edit </a>&nbsp&nbsp&nbsp&nbsp<a href = "editEmp.jsp?id=<%= empSno %>&&delete=yes"> Delete </a>
                             </td>
                        </tr>
    now i want to use html:link action in place of HREF can u help me plzzzzzzzzzz

  • How to pass request parameters using html:link in struts

    Hi All,
    I am trying to send parameters to action class using <html:link>.
    Can anybody give sample code how to do it?
    Thanks in advance.
    By
    K.Siva Prasad Reddy

    hi,
    you can pass the parameters in link like this
    http://www.xyz.com&username=someuserID&password=somePassword
    username and password are parameters which you want to pass as paramets to server..hope this will work for you...
    Thanks
    Surya

  • How to use the html:link with a arraylist

    Hi everyone:
    I want to display the data using struts html:link.
    I query the database and place all the data to javabean,later place all the javabean to ArrayList.In Action,I use the "request.setAttribute("lovetable",articlelist) to set request to jsp page.
    I want to pass a parameter "id" use the hyperlink so I can get the parameter when I click the hyperlink.
    But how to use html:link to display it?
    I use <html:link action="viewtopic.do" paramId="id" paramName="lovetable" paramProperty="id"/>,it can't work and Tomcat report error :
    org.apache.jasper.JasperException: No getter method for property id of bean lovetable
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    The lovetable is a ArrayList and it don't have a getter or setter method.
    How to use it pass parameter? :( Thks

    Thank you.
    I use the bean:define successful.And display all the data to jsp.My jsp code is:
    <logic:iterate id="love" name="lovetable">
    <bean:define id="idbean" name="love"/>
    <tr bgcolor="<%=color%>">
    <td><bean:write name="love" property="id"/></td>
    <td><html:link forward="viewtopic" paramId="id" paramName="idbean" paramProperty="id"><bean:write name="love" property="title"/></html:link></td>
    <td><bean:write name="love" property="name"/></td>
    <td><bean:write name="love" property="time"/></td>
    </tr>
    </logic:iterate>
    In Action : request.setAttribute("lovetable",articlelist)
    ResutlSet rs=.............
    List articlelist=new ArrayList();
    while(rs.next()){
    articlebean bean=new articlebean();
    bean.setName(rs.getString("name"));
    bean.setTitle(rs.getString("title"));
    articlelist.add(bean);
    The above code will work property.
    The Tag "html:link" need bean to work other than arraylist so I iterate all the bean out.
    The Tag "logic:iterate" need collection to work so I make Action return a List.
    right?
    Any idea? :)

  • Having problems passing more than one parameter with html:link tag

    Hi guys,
    for my web application I�m using Struts. I�ve got a database with user details. I would like to get users list and link to the details of each user. I wrote the code and everything is working fine only the users list is repeating as many times as users in the list.
    For ex: I have in the database User1, User2 and User3. I would like to have a result like:
    User1
    User2
    User3
    Instead of it I have the result like:
    User1
    User2
    User3
    User1
    User2
    User3
    User1
    User2
    User3
    What I�m doing wrong? Could somebody help me please?
    Thank you in advance
    There is a snippet of the code, which I�m using in jsp:
    <code>
    <logic:iterate id="root" name="user">               
                   <%
                        java.util.HashMap users = new java.util.HashMap();
                        params.put("user",root);
                        pageContext.setAttribute("usersName", users);
                   %>
                   <html:link name=" usersName " scope="page" page="/name.do">
                        <logic:iterate id="folder" name="user">
                             <bean:write name="folder" /><br>
                        </logic:iterate>
                   </html:link><br>
                   </logic:iterate>
    </code>

    Suggestion: next time you post code use the "CODE" button to put code tags around it. It formats much nicer that way :-)
    You have a nested loop structure here.
    <logic:iterate id="root" name="user">
      <%
        java.util.HashMap users = new java.util.HashMap();
        params.put("user",root);
        pageContext.setAttribute("usersName", users);
      %>
      <html:link name=" usersName " scope="page" page="/name.do">
        <logic:iterate id="folder" name="user">
          <bean:write name="folder" /><br>
        </logic:iterate>
      </html:link><br>
    </logic:iterate>Both loops iterate over your "user".
    Your first loop loops over each user.
    Then your second loop also loops over each user - hence you get number of users * number of users = 3 groups of 3.
    If you have 4 users, you would have 4 groups of 4.
    I only see you setting one parameter: "usersName" What other parameters do you need to pass?
    At a guess, the inner loop is unnecessary, and you want to write the users name as the text for the link, and also use it as a link parameter.
    <logic:iterate id="root" name="user">
      <%
        java.util.HashMap users = new java.util.HashMap();
        params.put("user",root);
        pageContext.setAttribute("usersName", users);
      %>
      <html:link name="usersName" scope="page" page="/name.do">
          <bean:write name="user" /><br>
      </html:link><br>
    </logic:iterate>

  • Html:link and javascript

    Maybe I'm asking the wrong question, how do you execute JavaScript within a <html:link> tag in Struts. I simply want to execute a collapse / expand divs with an onclick attribute in the <html:link> tag.
    Can this be done with some other tag?
    TC

    and why didnt u try putting the onlick tag ?
    <html:link href=# onClick="myJSfunction()">Rohit</html:link>
    -Rohit

  • html:link action="/...." not working

    hi eve,
    i am trying to add this line <html:link action="/prepareSimple"> then the following error is comming
    org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 39
    36:
    39:           <html:link action="/prepareSimple">
    40:           <img src="images/execute.gif" alt="" hspace="4" border="0" align="top" class="inline" />
    41:           </html:link>
    42:           <html:link action="/prepareSimple">Execute</html:link>
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:518)
         javax.servlet.ServletException: java.lang.NoClassDefFoundError
    ava.lang.NoClassDefFoundError
    my struts-config.xml is
    <action path="/processSimple"
                        type="examples.simple.ProcessSimpleAction"
                        name="simpleForm"
                        scope="request"
                        input="/jsp/simple/Simple.jsp"
                        validate="true">
                   <forward name="success" path="/jsp/simple/SimpleResults.jsp"/>
              </action>
    can someone help me where i am wrong????????????

    Try to add a type.
    See http://en.wikipedia.org/wiki/Favicon

  • Html link not visible as table header in jsp

    Hi,
    I am not sure if this question belongs to JSP forum, since it's happening in JSP page I am posting it here.
    I am seeing this strange problem, in my JSP page all the link are looking fine except some links in Table header. Here is the code snippet:
    <th align="left" width="30%"><html:link action="/myAction.do?sortBy=org&all=${param.all}">Organization Name</html:link></th>
    ENV is struts, jstl, html.
    Now the problem is the text Organization Name is not visible, although it's there and I can click it. If I click and drag mouse over it I can see it.
    Also if I put this link anywhere else e.g. <TD> I can see it.
    I am not sure why it's happening.
    Please help me.
    Abhishek

    Sounds like a style issue - is it the same colour as the background for some reason?
    What styles have you got applied to your <th> columns? The text in them?
    Are you using css?

Maybe you are looking for

  • Incoterms in PO line item

    Hi, As the Vendor Inco terms in PO header is getting populated from the vendor master...similarly Inco terms in PO Line item gets populated fromArticle PIR...If its blank then it doesnt get any value & if the same is maintain in PIR manually then Inc

  • Install FCE HD 3.0?

    Hi I am trying to install my FCE HD 3.0 upgrade on my 17" core 2 duo imac and am stumped. I have the required video card but this is not recognized by the installer and it quits. It also disables my older FCE program. I understand there is a patch fo

  • Help files for Audition v1.5

    I am looking for a download of help files for Audition v1.5 so I do not need to be online to get help.  I was hoping to find it as a pdf or a chm file.

  • Machine freeze, timeout waiting for nf to load

    my imac27 was randomly freezing requiring reboot, other times kernel panicking. apple changed the logicboard after doing some diagnostics. for a while it was fine -- then began freezing again. console logs seem to show the following repeated kernel e

  • HT1270 how to uninstall application

    how to uninstall application?