• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

how to send parameter in <html:link> tag

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
Say you have a hyperlink list that's built in a loop. The number of items in the list can vary based on the records in the database use to build the list. The text for each link is created based on a database lookup.
Each element in the list has it's own personnel information. Clicking on any of the links in the list would take you to another JSP page, where I want to display "Detail" information for the link clicked in the previous JSP page.
Therefore, my (basic?) question is how can you send the next JSP page specific information about the link that was clicked to call it?
I have code in jsp like:

<%
List<SelectForm> list=(List<SelectForm>)request.getAttribute("list");
Iterator ir =list.iterator();
%><html:form>
<table cellpadding="1" cellspacing="1" border="1" align="left" style="font-family: cursive;">
<tr style="color: maroon;"><th bgcolor="Pink" style="width: 100px;"> Firstname </th><th bgcolor="Pink" style="width: 100px;"> Lastname </th><th bgcolor="Pink" style="width: 100px;"> Country </th><th bgcolor="Pink" style="width: 200px;"> EmailId </th></tr>
<%
while(ir.hasNext())
{
sf=(SelectForm)ir.next();
<tr><td>
<%= sf.getFirstname() %>
</td><td>
<%= sf.getLastname() %>
</td><td>
<%= sf.getCountry() %>
</td><td>
<html:link action="/information" onfocus="focus()"><font color="#00FF00">
<%= sf.getEmailid() %></font></html:link>
</td>
<%
}
%>
</table></html:form>
here sf.getemailid() is in link form.

Thanks in advance for any ideas.
 
Pawan Singh
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the solution by my own
you just have to set the object in pagecontext.setattribute(String arg0, Object arg1)
then <html:link action="......" paramid="XXX" paramName="String arg0"/>

you can retrieve this parameter in your action class as :
request.getParameter("XXX"/paramid);


here in code view:


<%String mail=sf.getEmailid();
pageContext.setAttribute("emailid",mail);%>

<html:link action="/information" onfocus="focus()" paramId="mailid" paramName="emailid" scope="request"><font color="#00FF00">

<%= sf.getEmailid() %></font></html:link></td>
<%}%>



here sf.getEmailid() is a String type Object which i have to pass as a parameter from a jsp to action class in link form.
hope you like this , and definetly it will work.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!