简体   繁体   中英

How to open a new page when button is clicked on

The question is vague so allow me to clarify. I am developing a web app locally on eclipse and using Servlets, JSP, and an html document to design a web page.

I have a home page which has two buttons, signup and login. I have one file, called index.jsp, which has the html configurations of the homescreen.

So, when signup is clicked on, how can I get the server to load a new page with text input boxes?

Thanks.

要打开新窗口/选项卡,请使用空白目标:

<a href="SIGNUP_PAGE" target="_blank">Sign Up</a>

You can send the request from one jsp to another. Lets say after the index.jsp you want to go to login.jsp when the button is pressed.Then create a form like this:

<form action="login.jsp">
<input name="username" type="text"><br>
<input name="password" type="password">
<input type="Submit" value="Login">
</form>

Now in the login.jsp you can get the username and password using

String username=request.getParameter("username");
String password=request.getParameter("password");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM