[opencms-dev] A method into a JSP

Rafael Diaz Valdes Rafael.Diaz.Valdes at cern.ch
Wed Dec 15 15:15:34 CET 2004


Hi Robert and all 
Following your instruction I solve the error but I have a new one
 
 javax.servlet.ServletException: Resource loader error in file '/NewAlicePortal/en/Collaboration/Site_Admin/CreateWebUserForm.jsp'
Root cause:
org.apache.jasper.JasperException
 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
 
The problem is that  this line " Vector vector = cmso.getChild(groupName); " in my method doesn't work. I don't know why. I goin to explain my JSP. First I check the user access right, after that I collect all the projects manageables by the User, then I prepare a form to select a project (its work perfect), if you select a project name  other form in called to select the groups of this project, the is when the method is used, please can you check all the jsp??
 
<%@ page import="com.opencms.flex.jsp.*,com.opencms.core.*, com.opencms.file.*, java.lang.*,java.util.*" %>
<%!
 void FindChilds( java.lang.String groupName, com.opencms.file.CmsObject cmso)
                         throws com.opencms.core.CmsException {
                 Vector vector = cmso.getChild(groupName);
                  int size = vector.size();
            if(size == 0){
              System.out.println("<option>" + groupName + " </option>") ;
              return;
            }else{
                int n=0;
                while(n<size){
                      CmsGroup childgroup = (CmsGroup)vector.get(n);
                      String childgroupName = childgroup.getName();
                      FindChilds(childgroupName, cmso);
                      n++;
         }
            return;
           }
  }
      
%>
<%
 // initialise Cms Action Element
CmsJspActionElement cms = new CmsJspActionElement( pageContext, request, response );
CmsObject         cmso  = cms.getCmsObject();
CmsRequestContext rcont      = cmso.getRequestContext();
 
// include the "head" of the global .jsp defined in the template property
cms.include(cms.property("template"), "head");
// include the check access rigth
Boolean showBody = Boolean.TRUE;
rcont.setAttribute("showBody",showBody);
cms.include("/system/modules/com.opencms.aliceweb/elements/checkAccess.jsp");
showBody = (Boolean)rcont.getAttribute("showBody");

//
// the body element
if ( showBody == Boolean.TRUE ) { // check access
String queryProject = request.getParameter("queryProject");

// Collect all the projects manageables to this user (projectManager)
Vector projects = cmso.getAllManageableProjects();
int size = projects.size();
if( queryProject == null ){
  queryProject = "*";
  if(size>0){
%>
           <b>Please select the project where you want to include the new webuser</b>
          <form name="select_project" method="get">
           <table>
           <tr>
          <td align="left"> Project:  </td>
          <td>
          <select size="1" name="queryProject">
<%
           int n=0;
           while(n< size) {
                   CmsProject proj = (CmsProject)projects.get(n);
                   String projName = proj.getName();
%>
                 <option> <%= projName%> </option>
<%
                 n++;
           }
 %>
          <option selected>*</option>
          </select>
          <input type="submit" value="select">
         </td>
         </tr>
         </table>
         </form>
<%
  } 
 }else{          
          
              int i=0;
               int GroupID = 0;
              while(i< size) {
                   CmsProject project = (CmsProject)projects.get(i);
                   String projName = project.getName();
                   if(projName.equals(queryProject)){
                       GroupID = project.getGroupId();
                       break;
                   }
                   i++;
              }
              if(i < size){
                 CmsGroup group = cmso.readGroup(GroupID);
                 String groupName = group.getName();
                 Vector childs = cmso.getChild(groupName);
                 int childssize = childs.size();
                 
%>
                 <form action= "<%=cms.link("/system/modules/com.opencms.aliceweb/elements/addwebuser.jsp") %>" method="post">
                 <table>
                 <tr>
                 <td> Group:  </td>
                 <td>
                 <select size="1" name="WebUserGroup">
<%
                 
                 int j=0;
                 while(j< childssize) {
                      CmsGroup childgroup = (CmsGroup)childs.get(j);
                      java.lang.String childgroupName = childgroup.getName();
                       FindChilds(childgroupName,cmso);
                                
                        
                       j++;
                 }
 %>
                 <option selected>*</option>
                 </select>
                 </td>
                 </tr>
                 <tr>
                 <td>
                 Webuser Name:
                 <input type="text" id="WebUserName " name="WebUserName" size="10" value="">
                 Password:
                 <input type="password" id="WebUserPassword" name="WebUserPassword" size="10" value="">
                 </td>
                 </tr>
                 </table>
                 </form>
<%
              }
       }
}
else {
   cms.include("/system/modules/com.opencms.aliceweb/elements/errorAccess.jsp" );
}
cms.include(cms.property("template"), "foot");

%>

 
Rafael
 
 
 

	-----Original Message----- 
	From: opencms-dev-bounces at opencms.org on behalf of Robert Burén 
	Sent: Wed 12/15/2004 12:15 PM 
	To: The OpenCms mailing list 
	Cc: 
	Subject: Re: [opencms-dev] A method into a JSP
	
	

	Just do exactly what the error message says: catch the exception, or
	declare that it can be thrown in the method. For example, to declare
	it in your method, change the lines:
	
	  void FindChilds( String groupName, HttpServletRequest request,
	                          HttpServletResponse response){
	
	to read:
	
	  void FindChilds( String groupName, HttpServletRequest request,
	                          HttpServletResponse response)
	                          throws com.opencms.core.CmsException {
	
	
	Regards,
	
	/Robert
	
	
	
	On Wed, 15 Dec 2004 12:07:04 +0100, Rafael Diaz Valdes
	<Rafael.Diaz.Valdes at cern.ch> wrote:
	> Hi, list
	>
	>  I have  to include a method into a jsp in order to make a look for all subgroups of a group, This is my method :
	>
	> <%@ page import="com.opencms.flex.jsp.*,com.opencms.core.*, com.opencms.file.*, java.lang.*,java.util.*" %>
	>
	> <%!
	>  void FindChilds( String groupName, HttpServletRequest request,
	>                          HttpServletResponse response){
	>
	>     CmsJspActionElement cms = new CmsJspActionElement( pageContext, request, response );
	>     CmsObject         cmso  = cms.getCmsObject();
	>
	>                Vector vector = cmso.getChild(groupName);
	>             int size = vector.size();
	>             if(size == 0){
	>               System.out.println("<option>" + groupName + " </option>") ;
	>               return;
	>             }else{
	>                 int n=0;
	>                 while(n<size){
	>                       CmsGroup childgroup = (CmsGroup)vector.get(n);
	>                       String childgroupName = childgroup.getName();
	>         FindChilds(childgroupName, request, response);
	>         n++;
	>          }
	>             return;
	>            }
	>   }
	> %>
	>
	> But I recive this error :
	>
	> Root cause:
	> org.apache.jasper.JasperException: Unable to compile class for JSP
	> An error occurred at line: -1 in the jsp file: null
	> Generated servlet error:
	>     [javac] Compiling 1 source file
	> /usr/local/jakarta-tomcat-4.1.29/work/Standalone/localhost/opencms/WEB-INF/jsp/offline/NewAlicePortal/en/Collaboration/Site_Admin/CreateWebUserForm_jsp_jsp.java:22: unreported exception com.opencms.core.CmsException; must be caught or declared to be thrown
	>                Vector vector = cmso.getChild(groupName);
	>                                             ^
	> 1 error
	>
	> Someone have an idea to solve this error ??.
	> Best Regards
	>  Rafael
	>
	>
	>
	>
	> _______________________________________________
	> 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
	>
	>
	
	
	_______________________________________________
	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
	

-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 22126 bytes
Desc: not available
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20041215/9cb9aec7/attachment.bin>


More information about the opencms-dev mailing list