com.code.servlet
package com.code.servlet; import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import com.domain.bean.TmpBean;
import com.service.impl.CodeSericeImpl;
import com.service.impl.CodeServiceDao; public class AddConditionServlet extends HttpServlet { /**
* 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 {
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
String referer = request.getHeader("referer");
if(referer == null){
response.sendRedirect(request.getContextPath() + "/index.jsp");
return;
} String vallist = request.getParameter("txtcondition");
String mscript = request.getParameter("txtmscript");
if (vallist == null || vallist.equals("")) {
request.getRequestDispatcher("/WEB-INF/jsp/addcontidion.jsp")
.forward(request, response);
return;
} if (mscript == null && mscript.equals("")) {
request.getRequestDispatcher("/WEB-INF/jsp/code.jsp").forward(
request, response);
return;
}
if (mscript.contains("**") || mscript.contains("***")
|| mscript.contains("****")) {
request.getRequestDispatcher("/WEB-INF/jsp/addcontidion.jsp")
.forward(request, response);
return;
}
CodeServiceDao ssi = new CodeSericeImpl();
//mscript remove rule condition. eg. (n) (o) (p) mscript = ssi.removeRuleNumber(mscript); TmpBean tpb = (TmpBean) request.getSession().getAttribute("tpb");
tpb.setGetVarStr(vallist);
List<String> varlist = ssi.splitVariable2list(vallist); LinkedHashMap<String, String> valMap = ssi.varAdd2Map(varlist); // Pattern pattern = Pattern.compile("\\.*");
// Matcher matcher = pattern.matcher(mscript);
// String str = matcher.replaceAll("</br>"); // System.out.println(str); tpb.setMscript(mscript);
tpb.setVarMap(valMap);
System.out.println(tpb.getVarMap());
System.out.println(tpb.getMscript());
request.getRequestDispatcher("/customerVelocityServlet").forward(
request, response);
} public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { this.doGet(request, response);
} }
package com.code.servlet; import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import com.domain.bean.TmpBean;
import com.service.impl.CodeSericeImpl;
import com.service.impl.CodeServiceDao; public class CodeServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
String referer = request.getHeader("referer");
if(referer == null){
response.sendRedirect(request.getContextPath() + "/index.jsp");
return;
}
// String testcase = request.getParameter("testcase");
String testcontext = request.getParameter("testcontext"); if(testcontext==null||testcontext.equals("")){
request.getRequestDispatcher("/WEB-INF/jsp/code.jsp").forward(request, response);
return;
}
TmpBean tpb = new TmpBean();
tpb.setContex(testcontext);
CodeServiceDao ssi = new CodeSericeImpl(); // variable work*************************************************************
// List<String> varlist = ssi.splitVariable2list(testcase);
//
// LinkedHashMap<String,String> valMap = ssi.varAdd2Map(varlist);
// tpb.setVarMap(valMap);
// String varStr = ssi.varAppend(varlist);--will be use by other function
// ***************************************************************************** // context after format
String txtVal = ssi.StrAppend(testcontext);
txtVal = ssi.formatString(txtVal);
tpb.setLayout(txtVal);
request.getSession().setAttribute("tpb", tpb); request.getRequestDispatcher("/WEB-INF/jsp/addcontidion.jsp").forward(request, response);
} public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { this.doGet(request, response);
} }
com.code.servlet的更多相关文章
- 马士兵 Servlet & JSP(1) Servlet (源代码)
1.HTTP协议基础测试(获取页面源代码) import java.io.BufferedReader; import java.io.IOException; import java.io.Inpu ...
- 从servlet规范说起
servlet规范 1 servlet 3.1规范 1.1 What is servlet A servlet is a JavaTM technology-based Web component, ...
- httpServlet,GenericServlet,Servlet源码分析
httpServlet源码: /* * Licensed to the Apache Software Foundation (ASF) under one or more * contribut ...
- JavaEE-06 Servlet基础
学习要点 Servlet生命周期 Servlet API的常用接口和类 Servlet的部署和配置 Servlet处理用户请求 Servlet JSP回顾 JSP技术开发web应用在服务器端生成网页的 ...
- velocity properties
resource.loader=webapp webapp.resource.loader.class=org.apache.velocity.tools.view.servlet.WebappLoa ...
- spring mvc DispatcherServlet详解前传---HttpServletBean类
从上章里我们已经看到: DispatcherServlet extends FrameworkServlet FrameworkServlet extends HttpServletBean impl ...
- JSP(二)
一.pageContext对象 1>代表当前JSP页面的运行环境, [作用域仅仅局限于当前JSP页面中,出了该JSP页面, 原PageContext域对象被销毁] 2>封装了对 ...
- Spring Boot启动过程(四):Spring Boot内嵌Tomcat启动
之前在Spring Boot启动过程(二)提到过createEmbeddedServletContainer创建了内嵌的Servlet容器,我用的是默认的Tomcat. private void cr ...
- Cookie和Session总结
Cookie概述 Cookie是什么? Cookie是一小段文本信息,伴随着用户请求和页面在Web服务器和浏览器之间传递.Cookie包含每次用户访问站点时Web应用程序都可以读取 ...
随机推荐
- Java [Leetcode 42]Trapping Rain Water
题目描述: Given n non-negative integers representing an elevation map where the width of each bar is 1, ...
- NK 1137: 石子合并问题
1137: 石子合并问题 Time Limit: 1500 ms Memory Limit: 10000 kB Judge type: Multi-cases Total Submit ...
- 剑指Offer:连续子数组的最大和
题目: 输入一个整型数组, 数组里有正数也有负数. 数组中的一个或连续的多个整数组成一个子数组. 求所有子数组的和的最大值. 要求时间复杂度为O(n) #include <stdio.h> ...
- CSS3实现jquery的特效
实现 “慕课网” 的图片滑过缩放的效果 技术点:css3—— -webkit-transform:scale(1.2); .course-list-img .img_1:hover{ -webki ...
- Project Euler 26 Reciprocal cycles
题意:求1到n中所有数的倒数中循环小数循环体最长的数 解法:如果一个数的质因子只有2和5,那么这个数的倒数一定不是一个循环小数.如果一个数含有质因子2或5,那么它的循环体和去掉质因子2和5之后的数的循 ...
- POJ 1904 King's Quest 强连通分量+二分图增广判定
http://www.cnblogs.com/zxndgv/archive/2011/08/06/2129333.html 这位神说的很好 #include <iostream> #inc ...
- 求一字符串最长不重复字符子串的长度【Java 版】
一. 前言 最近学习有点断断续续,整理的一些知识点要么不完整,要么完全没搞懂,不好拿上台面,还是先在草稿箱躺着吧.偶尔在浏览大牛博客http://coolshell.cn的时候,发现大牛业余时间也在做 ...
- 输入一个整数n,求从1到n这n个整数的十进制表示中1出现的次数
题目:输入一个整数n,求从1到n这n个整数的十进制表示中1出现的次数.例如输入12,从1到12这些整数中包含1 的数字有1,10,11和12,1一共出现了5次. 分析:首先最先想到的是遍历从1到n的每 ...
- HDU2296——Ring(AC自动机+DP)
题意:输入N代表字符串长度,输入M代表喜欢的词语的个数,接下来是M个词语,然后是M个词语每个的价值.求字符串的最大价值.每个单词的价值就是单价*出现次数.单词可以重叠.如果不止一个答案,选择字典序最小 ...
- Apache Hadoop压缩包与Eclipse结合,导入jar包归整总结(手动)
************************* 有些,是没必要全导入的.以后到工作了,用Maven,就自动会导入其中一些.************************ 一般,工作中,用的更多 ...