请问如在输入错误信息后,在当前表单里提示错误信息
<%@ page language="java" import="com.crm.product.*,java.util.regex.*" pageEncoding="GBK"%>
<%@ page import="java.util.*,java.sql.Date"%>
<%@include file="_SessionCheck.jsp"%>
<%
List<Stock> stocks = Stock.getStocks2();
%>
<%
request.setCharacterEncoding("GBK");
String action = request.getParameter("action");
String Regexp = request.getParameter("Regexp");
String Regexp0 = request.getParameter("Regexp0");
if (action != null && action.trim().equals("add")) {
String strId = request.getParameter("id");
String[] str = strId.split(",");
int id = Integer.parseInt(str[2]);
String productname = request.getParameter("productname");
String model = request.getParameter("model");
String color = request.getParameter("color");
String price = request.getParameter("price");
String pdate = request.getParameter("pdate");
Pattern pattern = Pattern.compile("[0-9]*" );
Matcher matcher= pattern.matcher(price);
if(productname == "" ||color=="" || price=="" || pdate == ""){
String validate0="*Please complete all information";
response.sendRedirect("ProductAdd.jsp?Regexp0="+validate0);
}else if(matcher.matches()==false ){
String validate="* Format Error!";
response.sendRedirect("ProductAdd.jsp?Regexp="+validate);
}else{
Product p = new Product();
p.setId(id);
p.setProductname(productname);
p.setModel(model);
p.setColor(color);
p.setPrice(price);
p.setPdate(pdate);
p.add(p);
response.sendRedirect("ProductList.jsp");
}
}
%>
<html>
<head>
<title>添加产品</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" href="script/style1.css" type="text/css">
<script type="text/javascript">
function change(p) {
var product = p.value;
var products = new Array();
products = product.split(",");
var name = document.getElementById("productname");
var pcount = document.getElementById("pcount");
name.value = products[0];
pcount.value = products[1];
}
</script>
</head>
<body leftmargin="0" rightmargin="0" topmargin="0">
<br>
<br>
<table style="table-layout: fixed;" align="center" border="0"
cellpadding="0" cellspacing="0" width="97%">
<tbody>
<tr>
<td class="nav" align="left" nowrap="nowrap" width="90%">
客户关系管理系统 »
<br>
</td>
</tr>
</tbody>
</table>
<br>
<form method="post" name="register" action="ProductAdd.jsp"
onSubmit="this.regsubmit.disabled=false;">