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的更多相关文章

  1. 马士兵 Servlet & JSP(1) Servlet (源代码)

    1.HTTP协议基础测试(获取页面源代码) import java.io.BufferedReader; import java.io.IOException; import java.io.Inpu ...

  2. 从servlet规范说起

    servlet规范 1 servlet 3.1规范 1.1 What is servlet A servlet is a JavaTM technology-based Web component, ...

  3. httpServlet,GenericServlet,Servlet源码分析

    httpServlet源码:   /* * Licensed to the Apache Software Foundation (ASF) under one or more * contribut ...

  4. JavaEE-06 Servlet基础

    学习要点 Servlet生命周期 Servlet API的常用接口和类 Servlet的部署和配置 Servlet处理用户请求 Servlet JSP回顾 JSP技术开发web应用在服务器端生成网页的 ...

  5. velocity properties

    resource.loader=webapp webapp.resource.loader.class=org.apache.velocity.tools.view.servlet.WebappLoa ...

  6. spring mvc DispatcherServlet详解前传---HttpServletBean类

    从上章里我们已经看到: DispatcherServlet extends FrameworkServlet FrameworkServlet extends HttpServletBean impl ...

  7. JSP(二)

    一.pageContext对象    1>代表当前JSP页面的运行环境, [作用域仅仅局限于当前JSP页面中,出了该JSP页面, 原PageContext域对象被销毁]    2>封装了对 ...

  8. Spring Boot启动过程(四):Spring Boot内嵌Tomcat启动

    之前在Spring Boot启动过程(二)提到过createEmbeddedServletContainer创建了内嵌的Servlet容器,我用的是默认的Tomcat. private void cr ...

  9. Cookie和Session总结

    Cookie概述     Cookie是什么?       Cookie是一小段文本信息,伴随着用户请求和页面在Web服务器和浏览器之间传递.Cookie包含每次用户访问站点时Web应用程序都可以读取 ...

随机推荐

  1. 关于 mkimage

    在嵌入式系统中,Linux内核和根文件系统一般都与bootloader一起烧写在flash芯片中,系统启动后,bootloader将Linux内核压缩到RAM中,并把压缩的根文件系统复制到RAM中,然 ...

  2. CXF之四 cxf集成Spring

    CXF原生支持spring,可以和Spring无缝集成.WebService框架CXF实战一在Tomcat中发布WebService(二)通过Spring Web实现CXFServlet.下面将Spr ...

  3. codeforces 671B Robin Hood 二分

    题意:有n个人,每个人a[i]个物品,进行k次操作,每次都从最富有的人手里拿走一个物品给最穷的人 问k次操作以后,物品最多的人和物品最少的人相差几个物品 分析:如果次数足够多的话,最后的肯定在平均值上 ...

  4. 168. Excel Sheet Column Title

    Excel Sheet Column Title Given a positive integer, return its corresponding column title as appear i ...

  5. windows 下Python import 导入自定义模块

    周末在家研究这个东西,则找到解决方案. 费话少说,上代码 #定义一个自定义的函数,如下 #函数的名称必须是字母和数字的组合,不能用数字开头 #函数名后用小括号括住入参,可以用逗号分隔多个 #如果有返回 ...

  6. HIbernate学习笔记(五) 关系映射之一对多与多对一

    三.       多对一 –单向 场景:用户和组:从用户角度来,多个用户属于一个组(多对一 关联) 使用hibernate开发的思路:先建立对象模型(领域模型),把实体抽取出来. 目前两个实体:用户和 ...

  7. Java之DataInputStream和DataOutputStream-用流操作基本数据类型

    package FileDemo; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.Fi ...

  8. hdu 5505 GT and numbers

    GT and numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...

  9. TFS的使用

    1.http://www.kwstu.com/ArticleView/kwstu_201462311500744

  10. 移动端rem布局和百分比栅格化布局

    移动端的rem: 使用方法: 设置html的font-size,根据浏览器分辨率缩放 设置根元素font-size为100px这样好用的值,不要设为10px这样的: 然后获取浏览器的分辨率,也就是视口 ...