0
我已經使用下面的代碼來從index.jsp
調用conn.java
(servlet的)。有用。
<%@page import= "java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page import= "aa.conn" %>
<jsp:useBean id= "conne" class= "conn" scope= "session"/>
<jsp:setProperty name= "conne" property= "*"/>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP</title>
</head>
<body>
<link rel="stylesheet" href="rowcolor.css" type="text/css">
<%
conne.con(request, response);
ArrayList newlist=null;
newlist=(ArrayList)request.getAttribute("data1");
int noofrows=(Integer)newlist.get(0);
int q = noofrows/5;
if(noofrows%5!=0)
q+=1;
out.println("Pages --->>>");
for (int t = 1; t <= q; t++) {
out.println("<a href=index.jsp?id=" + t + " name=" + t + "id=" + t + ">");
out.println(" " + t);
out.println("</a>");
}
conne.disp(request, response);
conne.dispgraphtab(request, response);
%>
</body>
</html>
但是,下面的代碼不起作用。我想從graphcon.jsp
撥打NewServlet
。
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page import= "aa.NewServlet" %>
<jsp:useBean id= "co" class= "NewServlet" scope= "session"/>
<jsp:setProperty name= "co" property= "*"/>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
</body>
</html>
這段代碼有什麼問題?錯誤是:
exception
javax.servlet.ServletException: java.lang.InstantiationException: NewServlet
root cause
java.lang.InstantiationException: NewServlet
的
現在 - 你已經使用的代碼示例和問題陳述似乎是完全不相適應的,你可以花一些時間來進行格式化。 – anirvan 2010-12-01 06:29:46