首页 技术 正文
技术 2022年11月15日
0 收藏 909 点赞 4,652 浏览 1862 个字

安装myeclipse之后配置tomcat服务器,在window里选择servers

选择tomcat的文件夹路径(我的是从别人那里考过来的文件夹)

选中上enable即可

出现了这个界面

在这里可以打开或关闭服务器

打开服务器之后可以打开浏览器看看 tomcat服务器有没有打开

网址为http://localhost:8080/

然后新建一个网络工程叫 myJsp

然后就有以下这些

Open with 可以打开图形化的开发拖拽界面

然后右键new servlet程序

Jsp是显示界面 view

Servlet转交用户的请求 control

Java程序  是  model

mvc架构

写完程序之后打开网址

http://localhost:8080/myJSP/

在index.jsp里面编写程序,这是一个可以在

在浏览器端输入姓名,在java控制台中显示所输入的姓名程序

index.jsp程序为:

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

  <head>

    <base href="<%=basePath%>">

    

    <title>My JSP ‘index.jsp’ starting page</title>

<meta http-equiv="pragma" content="no-cache">

<meta http-equiv="cache-control" content="no-cache">

<meta http-equiv="expires" content="0">    

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

<meta http-equiv="description" content="This is my page">

<!–

<link rel="stylesheet" type="text/css" href="styles.css">

–>

  </head>

  

  <body> 

    This is my JSP page. <br>

    <font color="00#101">你好<font size="5">帅</font>!!!</font>

    <form action="testservlet" method="post">

    <table>

    <tr><td>姓名</td><td><input type="text" name="name"></td></tr>

    <tr><td>密码</td><td><input type="text" name="pwd"></td></tr>

    <tr><td><input type="submit" value="提交"></td></tr>

    </table>

    </form>

   <br></body>

</html>

经过 servlet传递

servlet关键程序为

public
void
doPost(HttpServletRequest request, HttpServletResponseresponse)

throws ServletException, IOException {

String i = request.getParameter("name");

test a = new test();//与下面java程序有关

a.wawa(i);

}

在console就能得到

在java程序中输出这个值

java程序为

public
class
test

{

public
void
wawa(String q){

System.out.print("姓名是"+q);

}

}

把这个工程部署到jsp服务器上 选adddeployment

选工程名

输入姓名按提交

如果在别人的电脑上访问

http://你的ip地址:8080/myJSP/也可以获取他输入的姓名(我测试时两台电脑都连的有线网络)

如果新增了其它的jsp文件,直接在路径后加上文件名,比如

http://你的ip地址:8080/myJSP/main.jsp

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,999
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,511
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,357
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,140
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,770
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,848