0

could anyone tell me if it is possible to pass parameters dynamically with HREF?

PageOne of jsp:

<%
while(rs.next())
{

%>
    <tr>
    <td><a href="coursedetails.jsp? value = <%= rs.getString(1)%>" > <%= rs.getString(1)%>      
       </a></td>
    <td name = <%= rs.getString(2) %> >  <%= rs.getString(2) %></td>
    <td> <%=  rs.getString(3) %> </td>
</tr>

<%   
 }
%>

PageTwo of jsp

// the following code does not seem right. 
String value = request.getParameter("value");
String name = request.getParameter("name");

2 Answers 2

1

Remove the blank spaces. Try this

<a href="coursedetails.jsp?value=<%= rs.getString(1)%>"><%= rs.getString(1)%></a>

Also there isn't any parameter named "name" in the URL. so request.getParameter("name") will always return null. To add a second parameter, you will have to add the "&" symbol as below

<a href="coursedetails.jsp?value=<%= rs.getString(1)%>&name=<%= rs.getString(something)%>"><%= rs.getString(1)%></a>
Sign up to request clarification or add additional context in comments.

Comments

0

I know its old post. I identify some Error.You dont pass name attribute.

<%
while(rs.next())
{

%>
    <tr>
    <td><a href="coursedetails.jsp?value="<%=rs.getString(1)%> "&name="<%=rs.getString(2)%> >      
       </a></td>
    <td name = <%=rs.getString(2)%> >  <%=rs.getString(2)%></td>
    <td> <%=rs.getString(3)%></td>
</tr>

<%   
 }
%>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.