前提条件是配置好tomcat:在tomcat的项目目录下新建一个hello文件夹
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/9c5099df0aa918564a445cd9ac9081a1.png)
1、hello.jsp
<html>
<head>
<title>HELLO JSP</title>
<body>
<%
out.print("Hello World!");
out.print("<h1>Hello World!</h1>");
out.print("<script type='text/javascript'>alert('Hello World!');</script>");
%>
</body>
</head>
</html>
2、input.html
<meta charset="utf-8">
<form action="input.jsp" method="post">
請輸入信息:<input type="text" name="msg" id="msg"/>
<input type="submit" value="發送">
</form>
3、input.jsp
<%
String str = request.getParameter("msg");
out.println("<h1>"+str+"</h1>");
%>
效果如下:
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/fb57412d808e50431326b8ac5a2e4d8f.gif)