Servlet + JSP + SQL question

I have a servlet that is executing a few queries against a database. I am fowarding the results to a jsp page to display the results. I have been able to do this. My problem is when my query selects more than one field I am unsure on how to read that into an array or something like that. All the results I have done so far have had multiple results but only from one field in the database. Here is my serlvet and jsp code. If some one could tell me how to read multiple field into an array and display them on a jsp page that would be great. Thank you
Servlet
package nnet;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.security.Principal;
import java.sql.*;
import java.sql.DriverManager;
* <p>Title: NNET</p>
* <p>Description: Northland Intranet</p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: NMI</p>
* @author not attributable
* @version 1.0
public final class home
extends HttpServlet {
//Initialize global variables
//Initialize queries
private static final String USERQUERY =
"SELECT public.tblindividual.firstname as firstname " +
"FROM public.tblloginname " +
"INNER JOIN public.tblindividual ON (public.tblloginname.indlink = public.tblindividual.indid) " +
"WHERE LOWER(public.tblloginname.loginname) = LOWER(?)";
private static final String MAINLINKQUERY =
"SELECT public.nnetsection.name " +
"FROM public.nnetsection " +
"WHERE public.nnetsection.posted = 'true'";
private static final String ANOUNCEMENTQUERY =
"SELECT public.nnetanouncement.anouncement, to_char(nnetanouncement.postdate,'MonthDD, YY') as postdate " +
"FROM public.nnetanouncement " +
"ORDER BY public.nnetanouncement.postdate DESC";
public void init() throws ServletException {
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
Connection con = null;
PreparedStatement stmt = null;
//Initialize Resultset objects
ResultSet namers = null;
ResultSet mainlinkrs = null;
ResultSet anouncementrs = null;
ResultSet anouncementdaters = null;
//Initialize Array Lists
ArrayList mainlinkresults = new ArrayList();
ArrayList anouncementresults = new ArrayList();
String firstnameresult = null;
Principal user = request.getUserPrincipal();
String username = user.getName();
Properties props = new Properties();
InputStream in = getServletContext().getResourceAsStream(
"/WEB-INF/sql.properties");
props.load(in);
in.close();
//get Users login name to pass on
try {
Class.forName(props.getProperty("connection.driver"));
con = DriverManager.getConnection(props.getProperty("connection.url"), props);
stmt = con.prepareStatement(USERQUERY);
stmt.setString(1, username);
namers = stmt.executeQuery();
while (namers.next()) {
firstnameresult = namers.getString("firstname");
//results.add(namers.getString("firstname"))
catch (SQLException ex1) {
catch (ClassNotFoundException ex) {
finally {
if (stmt != null) {
try {
stmt.close();
catch (SQLException e) {
e.printStackTrace();
stmt = null;
if (con != null) {
try {
con.close();
catch (SQLException e) {
e.printStackTrace();
con = null;
//get the main links to pass on
try {
Class.forName(props.getProperty("connection.driver"));
con = DriverManager.getConnection(props.getProperty("connection.url"), props);
stmt = con.prepareStatement(MAINLINKQUERY);
mainlinkrs = stmt.executeQuery();
while (mainlinkrs.next()) {
mainlinkresults.add(mainlinkrs.getString("name"))
catch (SQLException ex1) {
catch (ClassNotFoundException ex) {
finally {
if (stmt != null) {
try {
stmt.close();
catch (SQLException e) {
e.printStackTrace();
stmt = null;
if (con != null) {
try {
con.close();
catch (SQLException e) {
e.printStackTrace();
con = null;
//get the announcements to pass on
try {
Class.forName(props.getProperty("connection.driver"));
con = DriverManager.getConnection(props.getProperty("connection.url"), props);
stmt = con.prepareStatement(ANOUNCEMENTQUERY);
anouncementrs = stmt.executeQuery();
while (anouncementrs.next()) {
anouncementresults.add(anouncementrs.getString("anouncement"));
catch (SQLException ex1) {
catch (ClassNotFoundException ex) {
finally {
if (stmt != null) {
try {
stmt.close();
catch (SQLException e) {
e.printStackTrace();
stmt = null;
if (con != null) {
try {
con.close();
catch (SQLException e) {
e.printStackTrace();
con = null;
request.setAttribute("firstname", firstnameresult);
request.setAttribute("mainlink", mainlinkresults);
request.setAttribute("anouncement", anouncementresults);
RequestDispatcher rd =
request.getRequestDispatcher("home.jsp");
rd.forward(request, response);
//Clean up resources
public void destroy() {
JSP Page
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/sql" prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jstl/xml" prefix="x" %>
<html>
<head>
<title>
index
</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body {
     margin-left: 0px;
     margin-top: 0px;
     margin-right: 0px;
     margin-bottom: 0px;
-->
</style></head>
<body bgcolor="#008000">
<table width="100%" border="1" cellspacing="0" bordercolor="#000000">
<tr>
<td bgcolor="#FFFFFF"><h1>Welcome to NNET <c:out value="${requestScope.firstname}" /></h1>
</td>
</tr>
</table>
<br>
<table width="100%" border="0" cellspacing="0">
<tr>
<td width="150"><table width="100%" border="1" cellspacing="0" bordercolor="#000000" bgcolor="#FFFFFF">
<tr>
<td><strong>Main Links </strong></td>
</tr>
<c:forEach var="item" items="${requestScope.mainlink}">
<tr>
<td valign="top"><c:out value="${item}"/></td>
</tr>
</c:forEach>
</table>
<p> </p></td>
<td><table width="100%" border="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td valign="top"><h2>Announcements</h2>
<p>
<c:forEach var="item" items="${requestScope.anouncement}">
<c:out value="${item}" />
</c:forEach>
</p>
</td>
</tr>
</table></td>
<td width="150"> </td>
</tr>
</table>
</body>
</html>

OK if you look at the code I pasted above I have doen that. I hav ethat book and it is good. My question is how do I get the data read into a multidemisional array or an arraylist like I am using in the code above so I can access that on the jsp page. Can you give an example. Here is what I want . I have a table called anouncements with 3 fields (ID, name, url) I am returning say 10 results. I want to store them in a single arraylist or multideminsional array and call them on the jsp page. What syntax would I use on the servlet and on the jsp page for this? I know how to do it as seen above when I return only one field with many results from the database. Thank you in advance for any help

Similar Messages

  • Class not found javax.servlet.jsp.jstl.sql.Result in Richfaces

    When I try to run the richfaces application using Weblogic 10.3 AS and Netbean IDE 6.9.1, I found ClassNotFoundException on javax.servlet.jsp.jstl.sql.Result class.
    I class path the following libs.
    commons-beanutils-core-1.8.0.jar
    commons-digester-1.8.jar
    commons-fileupload-1.2.1.jar
    commons-io-1.2.jar
    commons-logging-1.1.1.jar
    glassfish.el_2.1.1.jar
    glassfish.jsf_1.2.9.0.jar
    javassist-3.8.0.GA.jar
    jhighlight-1.0.jar
    jsf-facelets.jar
    jsf-api.jar
    log4j-1.2.14.jar
    richfaces-api-3.3.0.GA.jar
    richfaces-impl-3.3.0.GA.jar
    richfaces-ui-3.3.0.GA.jar
    glassfish.jstl_1.2.0.1.jar
    Also I try to deploy without using some jar files already exists in application server.
    My web.xml configuration is-
    <context-param>
    <param-name>org.richfaces.SKIN</param-name>
    <param-value>#{skinSelector.skin}</param-value>
    </context-param>
    <context-param>
    <param-name>org.richfaces.CONTROL_SKINNING</param-name>
    <param-value>enable</param-value>
    </context-param>
    <context-param>
    <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
    <param-value>com.sun.facelets.FaceletViewHandler</param-value>
    </context-param>
    <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
    </context-param>
    <context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
    </context-param>
    <context-param>
    <param-name>org.ajax4jsf.SKIN</param-name>
    <param-value>skin_name</param-value>
    </context-param>
    <filter>
    <display-name>RichFaces Filter</display-name>
    <filter-name>richfaces</filter-name>
    <filter-class>org.ajax4jsf.Filter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>richfaces</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
    </filter-mapping>
    <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    <login-config>
    <auth-method>BASIC</auth-method>
    </login-config>
    <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
    </listener>
    <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    I also try to configure <library-ref>....</libray-ref> configuration in weblogic.xml and weblogic-application.xml and I also deploy JSF-2.0.war as library in application.
    Please
    h5.MUTU

    So why didn't you think that the JSP forum here wasn't a good place to ask JSP questions like this one?
    You can use <c:for-each> with a List. That's how it's designed. I don't understand why you say you can't. Perhaps you were confused by the SQL tags in JSTL. But anyway, you should just return a List from your EJB and forget about using obscure internal JSP classes.

  • Javax.servlet.jsp.jstl.sql.Result and arraylist

    Hi,
    I try to explain my problem, I have posted in another section of forum, but perhaps this is a better place:
    I'm trying to use MVC model, so I call an EJB from a servlet which returns me a javax.servlet.jsp.jstl.sql.Result object (this derive from a resultset of a query) and then I make this available to a jsp page.
    I've choosen to return an javax.servlet.jsp.jstl.sql.Result object because I'd like to use this syntax:
    <c:forEach var="profiloString" items="${listaProfili}" >
              ${profiloString.anything}
    </c:forEach>Now I need to put my listaProfili object in session and permit users of my application to add and delete items from it. Finally I will update my database with the new data from listaProfili object.
    If listaProfili is an arraylist I can easily add or delete item from it, but if it is a javax.servlet.jsp.jstl.sql.Result I don't know how I can do this.
    If I return an arraylist object instead of an javax.servlet.jsp.jstl.sql.Result object, I can't use "<c:forEach ..." syntax.
    Can anyone help me?
    Thanks.

    So why didn't you think that the JSP forum here wasn't a good place to ask JSP questions like this one?
    You can use <c:for-each> with a List. That's how it's designed. I don't understand why you say you can't. Perhaps you were confused by the SQL tags in JSTL. But anyway, you should just return a List from your EJB and forget about using obscure internal JSP classes.

  • Servlet/JSP question

    Hello guys I have just been reading the HeadFirst Servlet/JSP book from O'REILLY.
    I have used it as a workbook just to see how the framework are use. After ending this book I have planned to do some stuff by my self. I'm precisely in the last chapters of the book right now so I thought about headed toward the Servlet/JSP API. Well in there I found out that the information about JSP were all just about stuff which concerned the Container. I didn't find anything about the syntax used in JSP, the EL syntax nor how the JSTL 1.1 tags looks like! And there where nothing about the DD.
    So I'm wondering were I could fins this information, and why they aren't reserved in the JSP API?
    Another question, when was the JSP2.0/Servlet2.4 specification released?

    Which edition of the book were you reading? It should have covered EL and JSP syntax right?
    Servlet2.4/JSP2.0 has been around for at least 5 years. Can't remember the exact date, but the specification was finalised November 2003.
    The JSP API is from the programming perspective. Tag library documentation is seperate.
    Useful links for you:
    [JSP reference |http://java.sun.com/products/jsp/docs.html] - JSP tags and EL.
    [JSTL Apis|http://java.sun.com/products/jsp/jstl/reference/api/index.html] THE reference for JSTL. Don't be afraid of the JSTL specifications. They are quite readable, and document all the JSTL tags fully. I refer to them constantly.
    Cheers,
    evnafets

  • Problem: package javax.servlet.jsp does not exist

    I am a novice JSP programmer. My projects that use any javax.servlet classes are not seeing those at all. I am working with a group of folks using Java SE 1.5. (Note: I'm using Windows so the directory separator is "\")
    What Used to work:
    1. Nearly all my projects were working using Java version 1.6. These projects were developed as examples from Wrox and Apress books about JSP and Struts.
    What has changed:
    1. I un-installed the version 1.6 of JDK and JRE, as well as tomcat, netbeans, and all the associated libraries/jars.
    2. I installed version 1.5 of JDK and JRE, as well as tomcat, netbeans, and all the associated libraries/jars.
    3. I updated my JAVA_HOME, CATALINA_HOME, CLASSPATH, and PATH environmental variables. I made sure that the path to servlet-api.jar (in the tomcat common\lib) is included in the classpath.
    What is wrong:
    1. References to javax.servlet.* are not satisfied--they are flagged in the source code in NetBeans and I get compiler errors with any project containing those references. For example:
    ... package javax.servlet.jsp does not exist
    import javax.servlet.jsp.*;
    What I've found:
    1. My CATALINA_HOME=C:\Java\Tomcat 5.5
    2. My JAVA_HOME=C:\Java\jdk1.5.0_11
    3. My CLASSPATH=.;C:\Program Files\QuickTime\QTSystem\QTJava.zip;%JAVA_HOME%\lib;%JAVA_HOME%\jre\lib;%JAVA_HOME%\lib\jsp-api.jar;%CATALINA_HOME%\common\lib\servlet-api.jar;C:\Java\logging-log4j-1.2.14\dist\lib\log4j-1.2.14.jar
    4. My PATH=c:\wint\BIN;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;%CATALINA_HOME%\bin;C:\MySQL\MySQL Server 5.0\bin;D:\MiKTeX 2.5\miktex\bin;C:\Perl\bin\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\SFU\Perl\bin\;C:\SFU\common\;C:\Program Files\Lahey-Fujitsu Fortran\v7.1\Bin;C:\Program Files\Lahey-Fujitsu Fortran\v7.1\Win32\Bin
    What I need:
    1. I need to have some reference to the servlet classes satisfied in my configuration. Any help is appreciated.
    thanks
    jondr

    Oh. I got some over-the-shoulder debug help.
    My error was in the classpath specification:
    The path: %JAVA_HOME%\lib\jsp-api.jar
    Should be: %CATALINA_HOME%\lib\jsp-api.jar
    That contains the javax.servlet.jsp.*
    Thimk.
    Message was edited by: jon
    jondr

  • "javax.servlet.jsp.JspException: null" When trying to use JSTL

    Hello,
    I am trying to use some taglibs from Apache but I am getting the following error when trying to access the relevant page:
    org.apache.jasper.JasperException: javax.servlet.jsp.JspException: null
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    org.apache.jasper.JasperException: javax.servlet.jsp.JspException: null
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
         org.apache.jsp.Questions_jsp._jspService(Questions_jsp.java:42)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    javax.servlet.ServletException: javax.servlet.jsp.JspException: null
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:854)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
         org.apache.jsp.WEB_002dINF.EL_005f2_jsp._jspService(EL_005f2_jsp.java:171)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
         org.apache.jsp.Questions_jsp._jspService(Questions_jsp.java:42)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    java.lang.reflect.InvocationTargetException
         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         java.lang.reflect.Method.invoke(Method.java:597)
         org.apache.taglibs.standard.tag.common.core.SetSupport.doEndTag(Unknown Source)
         org.apache.jsp.WEB_002dINF.EL_005f2_jsp._jspx_meth_c_set_0(EL_005f2_jsp.java:208)
         org.apache.jsp.WEB_002dINF.EL_005f2_jsp._jspService(EL_005f2_jsp.java:113)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
         org.apache.jsp.Questions_jsp._jspService(Questions_jsp.java:42)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)My web.xml file is as follows:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee/web-app_2_4.xsd"
    version="2.4">
    <display-name>Jsp_Ex09 - JSP Standard Tag Library</display-name>
    <welcome-file-list>
    <welcome-file>welcome.jsp</welcome-file>
    </welcome-file-list>
    <jsp-config>
    <taglib>
    <taglib-uri>/simplequestions</taglib-uri>
    <taglib-location>/WEB-INF/tlds/simplefaq.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
    <taglib-location>/WEB-INF/tlds/c.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
    <taglib-location>/WEB-INF/tlds/fmt.tld</taglib-location>
    </taglib>
    <jsp-property-group>
    <url-pattern>*.jsp</url-pattern>
    <el-ignored>false</el-ignored>
    <scripting-invalid>true</scripting-invalid>
    </jsp-property-group>
    </jsp-config>
    </web-app>I have the standard and jstl jars in my lib directory and the relevant tlds files int the tlds directory. I am using Tomcat 5.5 and J2EE 5.
    The jsp in question is as follows:
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
    <html>
    <head>
    <title>JSTL Q2</title>
    </head>
    <body>
    <h1>JSTL Question 2</h1>
    <h2>How do I use the JSTL?</h2>
    <jsp:useBean id="questions" class="com.apress.faq.Questions"
    scope="page">
    <jsp:setProperty name="questions" property="topic" value="EL"/>
    </jsp:useBean>
    <table border="1">
    <!-- the literal JSTL tag will be in left column of table -->
    <!-- the evaluated JSTL tag will be in right column of table -->
    <tr><th>tag</th><th>result</th></tr>
    <!-- this tag uses c:out to send the value of an EL to the response -->
    <tr><td><c:out value="${'${'}questions.topic}"/></td>
    <td><c:out value="${questions.topic}"/></td>
    </tr>
    <!-- this tag uses c:set to set the property of a JavaBean -->
    <c:set target="${questions}" property="topic" value="JSTL" />
    <tr>
    <td><c:set target="${'${'}questions}" property="topic"
    value="JSTL"/>
    </td>
    <td><c:out value="${questions.topic}"/></td>
    </tr>
    <!-- this tag uses c:if to determine whether to create another row -->
    <c:if test="${questions.topic == 'EL'}">
    <tr><td>This row will not be created</td>
    <td></td>
    </tr>
    </c:if>
    <c:if test="${questions.topic == 'JSTL'}">
    <tr><td>This row was created because the c:if tag result was true</td>
    <td></td>
    </tr>
    </c:if>
    </table>
    <h2>Multiplication table, 1 - 5</h2>
    <!-use the forEach tag to create a table -->
    <table border="1">
    <tr><td></td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr>
    <c:forEach var="i" begin="1" end="5">
    <tr><td><c:out value="${i}"/></td>
    <c:forEach var="j" begin="1" end="5">
    <td><c:out value="${i*j}"/></td>
    </c:forEach>
    </tr>
    </c:forEach>
    </table>
    <h2>Formatting numbers</h2
    <br><fmt:formatNumber value="23.456" type="number" /> results in
    <fmt:formatNumber value="23.456" type="number" />
    <br><fmt:formatNumber type="currency">23.456
    </fmt:formatNumber> results in <fmt:formatNumber
    type="currency">23.456</fmt:formatNumber>
    <br><fmt:formatNumber value=".23456" type="percent"/> results
    in <fmt:formatNumber value=".23456" type="percent"/>
    <br><fmt:formatNumber value=".23456" type="percent"
    minFractionDigits="2"/> results in <fmt:formatNumber
    value=".23456" type="percent" minFractionDigits="2"/>
    </body>
    </html>Can anyone spot the problem?
    Sorry for such a big post!

    ava.lang.reflect.InvocationTargetException
         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         java.lang.reflect.Method.invoke(Method.java:597)
         org.apache.taglibs.standard.tag.common.core.SetSupport.doEndTag(Unknown Source)From the stacktrace, it appears to be from a <c:set> tag.
    Invocation target exception would meant that an error was encountered calling the setter.
    That would focus on this part of the code:
    <!-- this tag uses c:set to set the property of a JavaBean -->
    <c:set target="${questions}" property="topic" value="JSTL" />
    <tr>
    <td><c:set target="${'${'}questions}" property="topic"
    value="JSTL"/>
    </td>That nesting of ${ } inside ${} looks dodgy to me. What is it you are trying to achieve?

  • How to solve javax.servlet.jsp.JspException: duplicate Id for a component?

    Dear everyone,
    I have built some customized JSF components. In the taglib, there is attribute "id" for my components. There is no problem when the page is run, but when I click submit button, there are errors.
    javax.servlet.jsp.JspException: duplicate Id for a component form1:dojoComboBox1     at com.sun.faces.taglib.jsf_core.ViewTag.doAfterBody(ViewTag.java:191)     at _andychun._jspService(_andychun.java:190)     [andychun.jsp]     at com.orionserver[Oracle Containers for J2EE 10g (10.1.3.1.1) ].http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)     at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)     at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:598)     at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:522)
    Please kindly help solve this problem. Thank you.
    Best Regards,
    David

    Alex,
    my guess is that because you copied content from the
    first page to the next, you created JSF components
    with the same ID. JSF components must have unique IDs
    though.
    FrankHello Frank,
    Thanks for your reply. The thing is in the first page I do not have much id's specified/defined. And in the second page what I did was to take out all id's to see if it was conflicting. When I tried it again I still got the error. So the id's are being generated automatically if seems.
    Also is it that JSF components should have unique id's for a particular page or all pages in the JSF application?
    Any other sugguestions. I hope you understand what I am saying. If you have any questions or uncertainties fell free to ask me.
    Thanks,
    Alex.

  • Package javax.servlet.jsp does not exist.

    dear all!
    I've one program which import javax.servlet.jsp.* as one of the package to be used in
    the program, and I am using j2sdk 1.4.0_01 to compiled it.
    However I got this error message : package javax.servlet.jsp does not exist.
    Where does it wrong?.
    error message like :
    logisticslib.java:6: package javax.servlet.jsp does not exist
    import javax.servlet.jsp.*;
    ^
    logisticslib.java:201: cannot resolve symbol
    symbol : class JspWriter
    location: class elogistic.db.logisticslib
    public void getServiceInfo(JspWriter out, String SQL) {

    You need a J2EE implementation, I recomemend Tomcat, you also need to put the .jar w/ the implementation in in your classpath.

  • Why do we use both servlets & jsps in developing  an application ?

    why do we use both servlets & jsps in developing an application & not only jsps

    Hi,
    It's a pure question of design : Some like it jsp to jsp and others servlet to jsp. It's up to you to decide and it depends of the complexity of your application.
    But the best design is the MVC (servlet and jsp working together) because it helps you separate presentation from logic. It also helps you better maintain you code.
    You can have more info in javaworld.com.
    Good luck
    touco

  • Ejb + servlet + jsp

    Hallo everybody,
    i try to develop an application with servlet jsp and ejbs but i don't have enough information about this thema.
    for example i want to make a simple login szenario :
    user type the name and passwd and the system contact with the db and show a wellcome page if the login is succesfull and an error page if the login is unsuccessfull.
    which component does was??
    the first page can be a html form and post the name and passwd to a servlet.
    in this case servlet can make a connection with the DB and can forward the user to next page or error page. BUT where should i use EJB? can i realize the db connection with ejb ? if yes how can interact the servlet with the ejb and how can i store the information (for example address of user) which i have taken from the DB?
    thanks a lot

    Thanks for the antwort
    this means that the servlet connected to DB and execute the sql to authenticate user??
    and the second part is my bigger problem :)
    what does it mean "it will pass the control
    to the enterprise java bean which will be housing the business logic for your application."
    what does a java bean really do? how can i find information about them?
    and is ther an example in which i can see how servlets, jsps and beans interact??
    thanks

  • Javax.servlet.jsp.JspException: ObjectPersisterException thrown when loading pipeline

    avax.servlet.jsp.JspException: ObjectPersisterException thrown when loading pipeline due to: An error occurred when attempting to read the object from the database due to: An error occured when attempting to read object from table 'PIPELINE_SESSION' with id 'e7436af5851b0b4b3214b5f26f762a19' due to: com.humana.rightsource.beans.order.StatusIcon
    This happened when trying to load https://www.rightsourcerx.com/. Support at ttps://www.rightsourcerx.com/ informed me that a change had been made to there web site to make access from smart phones easier.

    I can load the page https://www.rightsourcerx.com/
    I am not sure this is a question within the scope of this forum.
    If you have problems with a web page because of the page design or changes to the webpage it is normally up to the website to sort that out.
    You could consider posting on a mozillazine forum to see what they say if you think it is a website problem.
    * http://forums.mozillazine.org/viewforum.php?f=25
    If the problem is with Firefox but not with other browsers see
    * [[Firefox can't load websites but other browsers can]]

  • Servlets , JSP, JSTL ,etc

    Hello
    In my Web project , I have used servlets, JSP , JSTL and JDBC to develop a Website, and now I am preparing a report about it.
    Please forgive me if this question sounds "not very smart" , but kindly help. Is it correct to mention in my report I have used J2EE techologies and then briefly explain about JSP, Servlets, etc?
    Thank you
    Vajra

    Well this really depends on what purpose your report serves and what the person/organization you're submitting your report to requires.
    What have you been told to do? Do you have any template that you need to follow?
    If you don't have any, then I guess you could add a section on the technology used and add a brief description covering this.
    But really, this totally depends on your situation and requirements. No one can tell you what to do. And you wouldn't blindly follow advice given by anonymous strangers on an Internet forum for an important project report now would you? :D

  • Why all classes in javax.servlet.jsp are abstract?

    Hi all,
    I have two questions about how the package was designed:
    1.) why all the classes in the javax.servlet.jsp are abstract? what is the benefits?
    2.) why almost all the methods in the class, such as jspWriter, are abstract too? And we can use these abstract methods in the way we use "concrete" methods?
    3.) the same thing for HTTPServlet class at javax.servlet package.
    Thanks in advance
    yllx

    Thanks for the message. In fact, you don't need to reply to the message if you don't have the answer.
    I suspect that this has something to do with the abstract factor design pattern. It allows each container engine to implement the detail based on its own specification. I just need some body to put more details on that.
    Since this happens quite often if the J2EE library, it's good for us to understand why they do this way, and how we can use it in our design.
    yylx

  • Best IDE for developing Applets,Servlets,JSP

    Hi,
    I'm looking for a little bit of advise. I have been developing prototypes using Apache Tomcat. Now I need to go into a full development phase, and I need an IDE to help speedup my work, especially when it comes to debugging applets and servlets. So the following are my questions:
    1. What is the best IDE to use in conjunction with Apache Tomcat? Does JBuilder, for example, fit this bill?
    2. Outside of Apache, I believe there is for example IBM's Websphere, which includes an IDE and a Servlet/JSP container. Which is the best of these packages?
    Thank you for your help.
    Miguel

    Check out NetBeans 3.5 at www.netbeans.org

  • Hosting a Servlet-JSP application onto Portal

    Hi,
    I have a scenario where I need to host a pure Servlet-JSP based application onto portal.
    This application is not developed using Web Dynpro. It is a pure java based application having two separate URLs for Dev and for Production.
    Now I want to give access point to this application via SAP Portal. How can I achieve it?
    Thanks and regards,
    Amey Mogare

    Thank you for reply Michael.
    Actually, this TestApp is already deployed on its Dev as well as Prod server as ear file. So we can use same ear file? If yes, then how? If not, then how do I go about?
    But I have one question here. How will we manage the different URLs of this application on portal?
    I mean, how would Production portal will know to point to production URL of this application???
    Thanks and regards,
    Amey Mogare
    Edited by: Amey Mogare on May 22, 2009 8:29 AM

Maybe you are looking for