Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2007

Tip: Looking for answers? Try searching our database.

View page without JSTL

Thread view: 
francan00@yahoo.com - 09 Dec 2007 23:31 GMT
I have a page that prints out a record using an object that comes from
a servlet.  I dont have JSTL (due to restrictions in my environment)
and need to show the JSP view without JSTL:

Here is the servlet part:

   public void doGet(HttpServletRequest  request,
                     HttpServletResponse response)
                       throws ServletException, IOException{

       AddressBook addressBook = new AddressBook();

       List addressRows = addressBook.getAllAddresses();

       request.setAttribute("addressRows", addressRows);

       request.getRequestDispatcher("/WEB-INF/webpage/
view.jsp").forward(request, response);
   }

JSP that works with JSTL:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<body>
       <c:forEach var="row" items="${addressRows}">
           ${row.firstname}
           ${row.lastname}
       </c:forEach>
</body>
</html>

Now my attempt to show the record without JSTL:
[code]
<%@page import="mypackagenamehere.*"%>
<html>
<body>
<%
out.println(new AddressBook().addressRows.toString());
%>
</body>
</html>

This gives me an error:
An error occurred at line: 29 in the jsp file: /WEB-INF/webpage/
view.jsp
Generated servlet error:
addressRows cannot be resolved or is not a field

Please advise how I can get this to work without JSTL in my Tomcat
4.1.3 container?
Wojtek - 09 Dec 2007 23:56 GMT
francan00@yahoo.com wrote :
> I have a page that prints out a record using an object that comes from
> a servlet.  I dont have JSTL (due to restrictions in my environment)
[quoted text clipped - 46 lines]
> Please advise how I can get this to work without JSTL in my Tomcat
> 4.1.3 container?

maybe: new AddressBook().addressRows().toString()

Note the two brackets after addressRows.

Signature

Wojtek :-)

Arne Vajhøj - 10 Dec 2007 00:38 GMT
> I have a page that prints out a record using an object that comes from
> a servlet.  I dont have JSTL (due to restrictions in my environment)
> and need to show the JSP view without JSTL:

>         AddressBook addressBook = new AddressBook();
>         List addressRows = addressBook.getAllAddresses();
>         request.setAttribute("addressRows", addressRows);
>         request.getRequestDispatcher("/WEB-INF/webpage/
> view.jsp").forward(request, response);

> <%@page import="mypackagenamehere.*"%>
> <html>
[quoted text clipped - 10 lines]
> Generated servlet error:
> addressRows cannot be resolved or is not a field

Try:

<%
List addressRows = (List)request.getAttribute("addressRows");
for(int i = 0; i < addressRows.size(); i++) {
    X row = (X)addresRows.get(i);
    out.println(row.getFirstname());
    out.println(row.getLastname());
}
%>

Arne


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.