紧急求救,还是那个问题(getinitparameter()和config对象)
web.xml内容
<web-app xmlns= "http://java.sun.com/xml/ns/j2ee " xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance " xsi:schemaLocation= "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd " version= "2.4 ">
<welcome-file-list>
<welcome-file> enter.jsp </welcome-file>
</welcome-file-list>
<servlet>
<servlet-name> connection </servlet-name>
<jsp-file> /connection.jsp </jsp-file>
<init-param>
<param-name> servername </param-name>
<param-value> sun1 </param-value>
</init-param>
<init-param>
<param-name> logid </param-name>
<param-value> test </param-value>
</init-param>
<init-param>
<param-name> logpass </param-name>
<param-value> test </param-value>
</init-param>
</servlet>
</web-app>
connection.jsp内容
<%@ page import= "java.util.* " %>
<%@ page import= "java.sql.* " %>
<%
String sServerName,sLogId,sLogPass;
sServerName=(String)config.getInitParameter( "servername ");
sLogId=(String)config.getInitParameter( "logid ");
sLogPass=(String)config.getInitParameter( "logpass ");
if( sLogId==null )
{
response.sendRedirect( "err_logid.html ");
return;
}
if(sServerName==null )
{
response.sendRedirect( "err_servername.html ");
return;
}
if(sLogPass==null )
{
response.sendRedirect( "err_logpass.html ");
return;
}
try
{Class.forName( "oracle.jdbc.driver.OracleDriver ");}
catch(
ClassNotFoundException e)
{
System.err.println( "1 "+e.getMessage());
}
String sUrl= "jdbc:oracle:thin@localhost:1521: "+sServerName;
Connection con=DriverManager.getConnection(sUrl,sLogId,sLogPass);
%>
每次都要检测到空,转到几个出错页面
------解决方案--------------------把
<context-param>
<param-name> servername </param-name>
<param-value> sun1 </param-value>
</context-param>
<context-param>
<param-name> logid </param-name>
<param-value> test </param-value>
</context-param>