Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

spring/jsp -exception

 
kanna kesavan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am getting a new exception which i have never faced before.kindly help me.I am using spring in jsp.This program works well if i run as stand alone program.i.e using main method .I have given my code and the exception is below:

<%@page import="java.util.*,javax.sql.*,javax.naming.*,org .springframework.jdbc.core.*" %>
<%@page import="org.springframework.jdbc.support.rowset.Sq lRowSet"%>
<%@page import="org.springframework.jdbc.support.rowset.Sq lRowSetMetaData" %>
<%!public List doSelect(String query)throws NamingException {
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "jnp://localhost:1099");

Context ctx = new InitialContext(env);
DataSource datasource= (DataSource) ctx.lookup("OracleDS");

JdbcTemplate jt = new JdbcTemplate(datasource);
SqlRowSet rowset = jt.queryForRowSet(query);
SqlRowSetMetaData rsmd = rowset.getMetaData();
int colCount = rsmd.getColumnCount();
System.out.println("colCount: " + colCount);

ArrayList rows = new ArrayList();
ArrayList list;
while (rowset.next()) {
list = new ArrayList();
for (int i = 1; i <= colCount; i++) {
list.add(rowset.getObject(i));
}
rows.add(list);
}
return rows;
}
%>
<html>
<head>
<title>JSP Page</title>
</head>
<body>
<h1 align="center">Welcome Admin</h1>
<form name="tableName" action="one" method="POST">
<%
List rows=doSelect("select * from tab where tabtype like 'SYNONYM'");
Iterator it=rows.iterator();
while(it.hasNext()){
ArrayList disp=(ArrayList)it.next();
Iterator it1=disp.iterator();
while(it1.hasNext()){
String str = (String)it1.next();
out.println("<option value=" + str + ">" + it1.next() + "str1"+ "</option>");
}
}
%>
</form>
</body>
</html>

OUTPUT:
org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:370)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:81)


root cause

java.util.NoSuchElementException
java.util.AbstractList$Itr.next(AbstractList.java: 422)
org.apache.jsp.AdminUI_jsp._jspService(org.apache. jsp.AdminUI_jsp:107)
org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:81)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic