Reputation: 1373
Is it possible to link a servlet within a list within a .jsp file ?
<form>
<ul id="nav">
<li class="current"><a href="HomeClientServlet">Home</a></li>
<li><a href="TransactionsServlet">Transactions</a></li>
<li><a href="StartTransferServlet">Transfer</a></li>
</ul>
</form>
The upper code wont work and im not sure how to do this.
*NOTE - The servlet needs to run doPost and not doGet.
As Jigar Joshi said I have tried to do this:
It didnt work and then i tried doing this instead:
<form>
<ul id="nav">
<li class="current"><a href="<%=request.getContextPath()%>/HomeClientServlet">Home</a></li>
<li><a href="<%=request.getContextPath()%>/TransactionsServlet">Transactions</a></li>
<li><a href="<%=request.getContextPath()%>/StartTransferServlet">Transfer</a></li>
</ul>
</form>
This one is invalid
<form>
<ul id="nav">
<li class="current"><form action="<%=request.getContextPath()%>/HomeClientServlet" method="POST"><input type="submit">Home</form></li>
</ul></form>
Upvotes: 0
Views: 227
Reputation: 123
You can do something like
< form method="post" action="<%=application.getContextPath()%>/Controller"> < ul> < li> < a href="javascript:callController()"> Controller < /a> < /li> < /ul>
And in the script part
function callController()
{
------- whatever be you want to do....
}
Upvotes: 0
Reputation: 240890
clicking on valid anchor by default makes a GET request, if you want to make a POST instead then either write javascript to handle on click and make POST or place a tiny form instead of anchor
replace anchor
tag with something like below
<form action="<%=request.getContextPath()%>/TransactionsServlet" method="POST">
<input type="SUBMIT">
</form>
Upvotes: 1