Search code examples
javajspservletshrefurl-pattern

passing parameter from jsp to servlet through url pattern of servlet


I got a requirement to send one parameter through url pattern of servlet (like we send through <a href="example.jsp?id=1">send</a>) in the same way I need it through url pattern.

I do this with other possibilities like

  1. I can send that parameter as hidden type
  2. i can put in a request and session objects

these methods are working fine no problem

but through url it's not taking? I want to know whether it is possible or not?

the code I have tried

jsp page

<a href="download?filename=<%=filename%>" target="_blank"> <font color="black"><%=filename%> </font></a>

servlet code

 String  filename=request.getParameter("filename");

and i need one answer can we pass parameter through url pattern if yes how? i.e like same as through <a href="example?id=1">send</a> or differently?


Solution

  • Yes you can send as like trough jsp.

    i just tested now it's working fine the blank page is coming because of other statements written in your servlet code so make sure servlet code is correct.