日期:2014-05-20  浏览次数:20837 次

无法调用servlet /relogin.jsp的service()方法
应用服务器:websphere(已设置好数据源jdbc/DLTK,测试通过)
数据库:DB2
我想通过文件relogin.jsp提取数据,可是运行时总是提示错误:“无法调用 servlet /relogin.jsp 的 service() 方法。抛出异常:java.lang.NullPointerException
哪位高手知道这是怎么回事?
relogin.jsp相关代码如下:
<%String ls_sql;
Connection conn = null; 
Statement stmt = null; 
Context context = null;
ResultSet rs = null;
DataSource ds = null;
ls_sql = "select username from HEYONG.WAS_USER";
ds =(DataSource)context.lookup("java:comp/env/jdbc/DLTK");
conn = ds.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery(ls_sql);%>

------解决方案--------------------
<%String ls_sql; 
Connection conn = null; 
Statement stmt = null; 
Context context = null; 
ResultSet rs = null; 
DataSource ds = null; 
ls_sql = "select username from HEYONG.WAS_USER"; 
ds =(DataSource)context.lookup("java:comp/env/jdbc/DLTK"); 
conn = ds.getConnection(); // 最好用之前测试下是否为空 应该是这行出问题了
stmt = conn.createStatement(); 
rs = stmt.executeQuery(ls_sql);%>
我的异常网推荐解决方案:Servlet.service() for servlet default threw exception,http://www.myexception.cn/eclipse/181756.html