vani
vani

Reputation: 101

How would i send a value from one jsp to another using the link

I have a jsp page where I have a link to "Creation.jsp" for which I have to pass the id.

I have used the following inside the anchor tag

href=/home/Creation.jsp?rad=<%=id%>

When i use like this, the actual id value is being displayed in the URL of the browser.

My question is : i dont want to display the value in the URL but want to send a value through the link from one jsp to another. How can I do this.

Upvotes: 0

Views: 3058

Answers (1)

Meherzad
Meherzad

Reputation: 8553

Create a link button of type submit and submit it via a form. In the form action give the name of the Creation.jsp page there you will be able to access the value if you have stored it in a invisible textbox.

<form action="Creation.jsp" method="post">

<input type= "hidden" value="<%=id%>" name="hdnId"/>

<input type="submit">

</form>

now on the Creation.jsp page get the value by request.GetParameter("hdnId");

Addition: Put this in the servlet

RequestDispatcher rd = request.getRequestDispatcher("Creation.jsp");
rd.forward(request, response);

refer http://docs.oracle.com/javaee/5/api/javax/servlet/RequestDispatcher.html

Upvotes: 2

Related Questions