开发者

How to process the value from a a:href

I have a JSP page:

<table width="40%" cellpadding="5" bordercolor="#000066" 
 bgcolor="#FFFFFF" border="1"   cellspacing="0">
 <c:forEach var="contactInfo" items="${contactsList}">
    <tr> 
         <td><div align="center">

        <b><a href="requestDelete.jsp?  id=${contactInfo.userID}">
            <c:out value="${contactInfo.contactName}"/></a></b>
             </div></td>
      </tr>

While clicking the link, i need to obtain the user_id, so that i can load details from the mysql db by passing the user_id and the details will be displayed in the requestDelete.jsp.

How to get the user_id in my servlet class after clicking the link.. or i need开发者_StackOverflow社区 to redirect the action to my servlet class...from there i can call the response page requestDelete.jsp

Please help..


<a href="requestDelete.jsp?id=${conatctInfo.userID}"><c:outvalue="${conatctInfo.contactName}"/></a>

This will create link like for example

requestDelete.jsp?id=50

Now you want this to be passed to some servlet so lets create one servlet, currently this will create a GET to jsp.

  • Create a servlet
  • Map it to some url pattern lets say /deleteUser

and modify your hyperlink to produce

/deleteUser?id=50

and in servlet's doGet()

long id= request.getParameter("id");
// some validation ans checks..
// call service to delete ..
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜