资源简介
1.简单的JSp连接oracle系统,很实用
2.包含数据库设计文档
3.包含oracle 中的sql语句文档
代码片段和文件信息
//======================== Addrbook.java =======================
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class Addrbook extends HttpServlet
{
public final int NUM_OF_PARAM = 6;
String userName;
ServletConfig config;
//
boolean error;
Enumeration params;
String[] errMark =
{““ ““ ““ ““ ““ ““};
public final String[] inputName =
{“name““sex““job““area““phone““email“};
public final String[] inputLabel =
{“姓名““性别““职业““区域号码““电话号码““信箱“};
//
public void init(ServletConfig config) throws ServletException
{
super.init(config);
this.config = config;
}
//
public void doPost(HttpServletRequest request
HttpServletResponse response)
throws ServletException IOException
{
ServletContext context = config.getServletContext();
String addrbook = context.getRealPath(“addrbook.txt“);
//
String name = request.getParameter(“name“);
userName = name;
String sex = request.getParameter(“sex“);
String job = request.getParameter(“job“);
String area = request.getParameter(“area“);
String phone = request.getParameter(“phone“);
String email = request.getParameter(“email“);
//
response.setContentType(“text/html; charset=Big5“);
PrintWriter pw=new PrintWriter(response.getOutputStream());
pw.println(““);
pw.println(“tle>addrbook tle>“);
pw.println(““);
params = request.getParameterNames(); //以下建立BODY内容
String s = ““;
String dbString = ““;
error = false;
for (int n=0; n {
s = request.getParameter(inputName[n]);
if (s.length() == 0)
{
switch (n)
{
case 0: //姓名name
case 1: //性别sex
case 2: //职业job
case 3: //区域号码area
case 4: //电话号码phone
errMark[n] = “ERROR“;
error = true;
break;
case 5: //信箱email
errMark[n] = “BLANK“;
break;
default:
}
}
dbString = dbString + s + ““;
}
if (error == true)
{
params = request.getParameterNames();
printErrorPage(pw params true);
}
else
printData(dbString addrbook pw); //BODY内容到此为止
pw.println(““);
pw.close();
}
//
public void printErrorPage(PrintWriter pw Enumeration e
boolean errorStatus) throws IOException
{
pw.println(“
下列栏位没填,请填妥后再递送
“);
for (int n=0; n {
if (errMark[n] == “ERROR“)
{
pw.println(““ + inputLabel[n] + “
“);
errMark[n] = ““;
}
}
pw.println(“