servlet的提交和动态改变有点依赖xml

我们点击控件的时候改变了里面的变量,改变了xml,servlet发现变量变了,就会刷新页面

如果xml文档没有更新,浏览器采用缓存而不则行

<form action='"+requestURI+"'method='get'>
<input type='text' name='param' value='param string'>
<input type='submit' value='用get方式查询"+requestURI+"'></form>

action后面接要发到文档的url,(这个代码是发到自己那里,然后自己的文档更新了,页面也动态更新)

method是我们人为控制用什么方法(get/post

后面有些变量,比如 param...我们后面可以用String param=request.getParameter("param");来获得他

package servlet;

import java.io.IOException;
import java.io.PrintWriter; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; public class FirstServlet extends HttpServlet { /**
* Constructor of the object.
*/
public FirstServlet() {
super();
} /**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
} /**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.execute(request,response);
} /**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.execute(request,response);
} /**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void execute(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
{
this.log("则行doget方法");
response.setCharacterEncoding("UTF-8");
request.setCharacterEncoding("UTF-8");
String requestURI=request.getRequestURI();
String method=request.getMethod();
String param=request.getParameter("param");
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");
out.println(method+"方式访问该页面。取到的para参数是"+param+"<br/>");
out.println("<form action='"+requestURI+"'method='get'><input type='text' name='param' value='param string'><input type='submit' value='用get方式查询"+requestURI+"'></form>");
out.println("<form action='"+requestURI+"'method='post'><input type='text' name='param' value='param string'><input type='submit' value='用post方式查询"+requestURI+"'></form>");
out.println("<script>document.write('本页面最后更新时间'+document.lastModified);</script>");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
}
public void init() throws ServletException {
// Put your code here
} }

servlet的提交的更多相关文章

  1. servlet自动获取前端页面提交数据

    servlet自动获取前端页面jsp提交数据 以下是本人在学习过程中,因前端页面提交参数过多,后台servlet封装实体类过于麻烦而写的一个工具类,应用于jsp/servlet数据提交后,基于MVC+ ...

  2. ajax提交数据到java后台,并且返回json格式数据前台接收处理值

    1.前台html页面.有一段代码如下: 账  户:  <input type="text" name="userName" id="userN& ...

  3. WEB启动时就加载servlet的dopost方法

    web启动的时候可以加载servlet的init方法,无法加载dopost方法,如果你需要什么内容在启动的时候执行,可以将内容放到init方法里面,dopost方法,是在客户端使用post请求的时候才 ...

  4. 5.servlet cookie自动登录的实例

    1.要建的文档,.java用servlet创建 2.建一张登陆表格 index.jsp <%@ page language="java" import="java. ...

  5. JavaWeb 之 重复提交表单和验证码相关的问题!

    下面我们首先来说一下表单的重复提交问题,我们知道在真实的网络环境中可能受网速带宽的原因会造成页面中表单在提交的过程中出现网络的延迟等问题,从而造成多次提交的问题!下面我们就具体来分析一下造成表单提交的 ...

  6. Servlet接收JSP参数乱码问题解决办法

    转自:http://lavasoft.blog.51cto.com/62575/274527/   环境: apache-tomcat-6.0.24.zip jdk1.6.0_16 WindosXP ...

  7. jsp+servlet+javaBean+Dao

    一.Servlet程序各模块介绍1.JSP 用于显示.收集数据的部分.2.Servlet 用于验证数据.实例化JavaBean.调用DAO连接数据库.控制页面跳转3.DAO 用于连接数据库及进行数据库 ...

  8. servlet学习总结

    一.web工程结构 1.HTTP协议(hyper text transfer protocol)(超文本传输协议) 机制:请求/响应 机制(request/response)(HttpServletR ...

  9. Servlet 2.3 规范

    Servlet2.3规范 第一章: servlet2.3规范用到了一下的一些规范:J2EE.JSP1.1.JNDI 在14章中讲述了规范中的所有的classes类或接口(改文中不讲述).对开发者而言以 ...

随机推荐

  1. 宝洁HR

    宝洁HR系统的测试犯了很多错误 1 最基本也是最弱智的错误:测试根本不仔细,多轮测试后仍然会发现前几轮应该发现的bug. 纠结测试不仔细的原因 a 个人工作坏习惯  老是认为理所当然,对于一些内容,总 ...

  2. [Exchange2013] 无法正常发送存入草稿箱 或者 只能发不能收

    可能是由于你的域控的DNS设置导致: 1.那么首先我们添加一个EX的记录在域控的DNS里面 2.登录exchange的控制台,设置DNS Server

  3. [svn] 数据库操作残留,无法进行操作的解决方法

    WINDOWS环境下的解决方法: 1: 下载sqlite3数据库工具,放置于SVN的同级目录 2: CMD路径转移到Sqlite3目录 3: 残留操作选择: sqlite3 .svn/wc.db &q ...

  4. Ethernet & IEEE 802.3 802.X 802.1ag-MEP

    ISO/IEC 7498标准,它定义了网络互联的7层框架,也就是开放式系统互连参考模型(OSI模型). 交换机好比是邻近的街道,而路由器则是街道的交汇点. (交换机第二层,即数据链路层,也有四层,七层 ...

  5. Java 集合框架 ArrayList 源码剖析

    总体介绍 ArrayList实现了List接口,是顺序容器,即元素存放的数据与放进去的顺序相同,允许放入null元素,底层通过数组实现.除该类未实现同步外,其余跟Vector大致相同.每个ArrayL ...

  6. 炮兵阵地 - POJ 1185(状态压缩)

    分析:先枚举出来所有的合法状态(当N=10的时候合法状态最多也就60种),用当前状态匹配上一行和上上一行的状态去匹配,看是否可以.....复杂度100*60*60*60,也可以接受. 代码如下: == ...

  7. thinkphp 比对过去时间距离现在时间多少的问题

    <?php import('ORG.Util.Date');// 导入日期类 $Date = new Date();//实例化类 $time_diff = $Date->timeDiff( ...

  8. UVa1572 UVaLive6393 Self-Assembly

    填坑系列(p.172) 注意“可以旋转和翻转” 然后将每个字母看成点 不然边数就是n^2级的 #include<cstdio> #include<cstring> #inclu ...

  9. 怎样给filter加入自己定义接口及调用

    本样例是在VirtualCamera的基础上加入的自己定义接口用来实现exe控制osd的显示. 1. 接口部分 #ifndef __H_MyFilter__#define __H_MyFilter__ ...

  10. CSS——(1)基础

    CSS(Cascading Style Sheets)层叠样式表 含义 一种计算机语言: 能够实现网页与内容分离: 用来表现文件样式,如HTML或XML: 比較 div与css 假设说div是容器的话 ...