Reputation: 31
I have a jsp
file where in I have a String
variable s. Now I want to pass this to a servlet
using servlet
.
In the href
tag i gave,
<a href="link?user= <%=s%> "> click me </a>
But it shows an error how else can I send this.
Please help me out..
Thanks
Upvotes: 0
Views: 14473
Reputation: 5178
This should work fine, but there are some minor mistakes here, which I'm not sure whether they are due to mis-typing here or there are actually in your code.
First have your link like this:
<a href="link?user=<%=s%> "> click me </a>
See? No spaces. And as your variable is s
, why using a
?
Second in your servlet use this to receive the parameter:
request.getParameter("s")
Upvotes: 2
Reputation: 3284
Do you actually have the spaces like that? Try this: "> click me
Upvotes: 0