编写两个jsp页面inputstring.jsp
时间: 2023-05-31 10:21:35 浏览: 91
### 回答1:
请问您需要关于b'\xe7\xbc\x96\xe5\x86\x99\xe4\xb8\xa4\xe4\xb8\xaajsp\xe9\xa1\xb5\xe9\x9d\xa2inputstring.jsp'的什么方面的回答呢?需要更详细的上下文信息才能给出准确的回答。
相关问题
编写两个JSP页面inputString.jsp和computer.jsp,用户可以使用inputString.jsp提供的表单输入一个字符串,并停交给computer.jsp页面,该页面通过内置对象获取inputString.jsp页面提交的字符串,并且是该字符串的长度
下面是inputString.jsp页面的代码:
```jsp
<html>
<head>
<title>输入字符串</title>
</head>
<body>
<h1>请输入一个字符串:</h1>
<form action="computer.jsp" method="post">
<input type="text" name="inputString">
<input type="submit" value="提交">
</form>
</body>
</html>
```
该页面中提供了一个表单,用户可以在文本框中输入一个字符串,并通过提交按钮将其发送给computer.jsp页面。
下面是computer.jsp页面的代码:
```jsp
<%@ page language="java" %>
<html>
<head>
<title>计算字符串长度</title>
</head>
<body>
<%
String inputString = request.getParameter("inputString");
int length = inputString.length();
%>
<h1>您输入的字符串是: <%= inputString %> </h1>
<h1>该字符串的长度是: <%= length %> </h1>
</body>
</html>
```
该页面通过内置对象request获取inputString.jsp页面提交的字符串,然后通过调用字符串的length()方法计算出字符串的长度,并将结果显示在页面上。注意,在JSP页面中,可以使用<% %>标记来插入Java代码,其中<%= %>标记用于输出表达式的值。
2.编写两个JSP页面login.jsp和handlestring.jsp,用户可以使用login.jsp提供的表单输入一个字符串,并提交给handlestring.jsp页面,该页面获取login.jsp页面提交的字符串,测该字符串的长度并显示。
login.jsp页面代码:
```jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Login Page</title>
</head>
<body>
<form action="handlestring.jsp" method="post">
<label for="inputString">Please input a string:</label>
<input type="text" id="inputString" name="inputString"><br/><br/>
<input type="submit" value="Submit">
</form>
</body>
</html>
```
handlestring.jsp页面代码:
```jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Handle String Page</title>
</head>
<body>
<%
String inputString = request.getParameter("inputString");
int length = inputString.length();
%>
<p>The length of the input string is: <%= length %></p>
</body>
</html>
```
当用户访问login.jsp页面时,会看到一个表单,输入一个字符串并提交。提交后,会跳转到handlestring.jsp页面,该页面获取login.jsp页面提交的字符串,并计算该字符串的长度并显示在页面上。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)