user1607653
user1607653

Reputation: 31

Is it possible to pass parameters to servlet/jsp using a href link?

Is it possible to pass parameters to servlet/jsp using a href link? If so can anybody give an example to show how it can be done?

Thanks

Upvotes: 0

Views: 7865

Answers (1)

Tomasz Nurkiewicz
Tomasz Nurkiewicz

Reputation: 340693

Of course:

<a href="link.do?user=31"/>

Read it in your servlet handling link.do URI:

public void doGet(HttpServletRequest req, HttpServletResponse resp) {
  req.getParameter("user")  //equals "31"
}

Or if it's a servlet (link.jsp):

<%= request.getParameter("user") %>

...or better with :

${param.age}

Upvotes: 2

Related Questions