Home > database >  How to add a parameter to the URL of a profile in Java Servlet
How to add a parameter to the URL of a profile in Java Servlet

Time:01-21

I have a JSP - File where you can see the User information, such as name ect (Like a profile). Now I want to create a Link, where you can access profiles with a unique code (that the user created) in the url. For example /webproject/user?id=293710

So the way this currently works is like that: You are able to login with your data, after you login, you're redirected to a dashboard with buttons, where you can view your profile, edit data etc. Here is a snippet:

<form method="GET" action="UserServlet">
    <input type="submit"  value="view Profile" />
</form>

Now when you press the button you get redirected to a view of your profile with your information excluding your password. It does show the information correctly, however it does not show the needed parameters in the URL. It's just a blank url="/webproject/user?" How can I change the URL to show for example the UserID?

I need the URL to be able to show the User Information of other Users with different ID's, and not just of the User in the Session. So when I edit the URL manually with a different ID, I need to see other User's profiles

Thanks in advance

CodePudding user response:

You can add a hidden input in the form containing the user id.

<input type="hidden" name="id" value="293710"/>
  • Related