[opencms-dev] Impossible to use jsp declarations ?

Alexander Kandzior alex at opencms.org
Fri Jun 13 11:21:00 CEST 2003


Nicolas,

you can't mix JSP declarations <%! ... %> with JSP output like <%= xxx
%>. This is so in all JSP, and it is not related to OpenCms. 

If your really need to write to your JSP inside your method, you must
pass the "out" object from the JSP to your method on calling. It would
look like this on your JSP:

<% listFilesAndFolders(out, cms, uri); %>

In your method, you need to use 

out.println("something");

Best Regards,
Alex.

Alexander Kandzior
Alkacon Software - The OpenCms Experts
http://www.alkacon.com

> -----Original Message-----
> From: opencms-dev-admin at opencms.org 
> [mailto:opencms-dev-admin at opencms.org] On Behalf Of Nicolas Delsaux
> Sent: Friday, June 13, 2003 10:42 AM
> To: opencms-dev at opencms.org
> Subject: Re: [opencms-dev] Impossible to use jsp declarations ?
> 
> 
> On Fri, 13 Jun 2003 09:52:45 +0200, Alexander Kandzior 
> <alex at opencms.org> 
> wrote:
> 
> > Nicolas,
> >
> > please post the relevant code of your JSP, otherwise I am unable to 
> > help.
> 
> OK, it may be a little long ...
> 
> <%@ page session="false" 
> import="com.opencms.flex.jsp.*,com.opencms.file.*,java.util.*"
>  %><%-- Linagora --%>
> 
> <%!
> public void 
> listFilesAndFolders(com.opencms.flex.jsp.CmsJspActionElement 
> cms, String uri) throws Exception {
> ArrayList files = new ArrayList();
> files.addAll(cms.getNavigation().getNavigationForFolder(uri));
> %><%= uri %><%
> if(files.size()) > 0) {
> %>
> <ul class="list-files">
> <%
> Iterator iter = files.iterator();
> CmsJspNavElement nav;
> String target;
> while(iter.hasNext()) {
> nav = (CmsJspNavElement) iter.next();
> if(nav!=null) {
> target = nav.getResourceName();
> %><li class="list-files"><%
> if(nav.isFolderLink()) {
> target = cms.link(target + "index.jsp");
> } else { // else if folderLink
> target = cms.link(target);
> } // end if folderLink
> %>
> <a class="list-files" href="<%= target%>"><%= 
> nav.getNavText() %></a> <%
> if(nav.isFolderLink()) {
> // listFilesAndFolders(cms, nav.getResourceName());
> }
> } // end if nav!=null
> } // end while
> %></ul><%
> } // end if size>0 } // end method %>
> 
> <% com.opencms.flex.jsp.CmsJspActionElement cms = new 
> com.opencms.flex.jsp.CmsJspActionElement(pageContext, 
> request, response); String uri = 
> cms.getRequestContext().getUri(); %> <%= uri %><% try { // 
> listFilesAndFolders(cms, uri); } catch(Exception e) { %> <%= 
> e.getClass().getName() %> <%= e.getMessage() %> <% } %>
> 
> Here it is.
> >
> > Best Regards,
> > Alex.
> >
> > Alexander Kandzior
> > Alkacon Software - The OpenCms Experts
> > http://www.alkacon.com
> >
> 
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, 
> please visit http://mail.opencms.org/mailman/listinfo/opencms-dev
> 
> 




More information about the opencms-dev mailing list