Jsp files in struts

Hi,
Is it possible to place the jsp files inside WEB-INF folder in a web
environment ?
I am using Tomcat.
Thanks,
Aarthy

You can put anything anywhere. Which is to say, you can put whatever you want in the WEB-INF directory. Except that this directory is not public and is not accessible via the clients ( read browsers ) so all you content in this folder is effectively invisible to the user. Which is a good thing since you don't people to access your web.xml or your classes and see what you're doing, do you? Also, you could put other files, like your PDFs, reports etc which you would like to serve up to users via a servlet but don't want them to have a direct link to.
So continuing along this line, you could put your JSPs in this folder, but no one will be able to access it. It will never run. So it doesn't make any sense.
Why do you want to put them there anyway?

Similar Messages

  • Can we keep one action file for all jsp files in struts?"

    I have 5-6 Jsp pages and all are inter connected.
    If any one make changes, these changes should be display in the database.
    In this case, I need only one Action class which can hold or manipulate all changes from all jsp pages. I am not sure "Can we keep one action file for all jsp files?"
    If yes, then how can we configure struts-config.xml file.
    If no, then pls suggest me any altenative solution.

    hai
    go for DispatchAction class and then pass as parameters
    refer struts complete reference...
    it will solve ur problems..

  • How to include .js file in jsp file?

    hi,
    i have a jsp file with struts tag. right now i have all the javascript code as a separate function inside the jsp file itself. i want the javascript code to be present in a .js file and i want to refer that .js file from the jsp file with struts tags.
    <html:text property="Phone" value="" size="3" maxlength="3"
         onkeyup="return autoTab(this, 3, event);"></html:text>
    the above is the html tag which will call the function "autoTab" of the .js file. please help.
    thanks,
    Jayanth.

    You include javascript into a jsp in exactly the same way you do with html
    <script src="myJavascriptFile.js"/>
    It has nothing to do with the jsp per se, but rather the generated HTML page.

  • Object Expected error in Struts JSP file

    Hi,
    I have a very simple JSP file as shown below.
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <%@ taglib uri="/tags/struts-html" prefix="html" %>
    <html>
    <head>
    <title>pqGlobalStoreProfile.jsp</title>
    </head>
    <body onLoad="getSessionData();disableFieldsLocale();">
    <html:form action="/pqGlobalStoreProfile.do">
    <table cellpadding=5 cellspacing=0>
         <tr><td colspan=2><h3><b>Pq Global Store/Modify Profile</b></h3></td></tr>
         <tr><td>Profile Key *</td><td><html:text property="profileKey"/></td></tr>
    </table>
    </html:form>
    </body>
    </html>
    It is throwing an "Object Expected' error at Line 9 Char 1.
    I am not sure about what is causing this error.
    Thanks.

    it's a Javascript error, cuz it's calling these 2 methods when the page loads...
    onLoad="getSessionData();disableFieldsLocale();"
    Where are these methods defined? Cuz I don't see any inline Javascript, nor a linked script.
    I hope you don't think that those onload functions are going to call Java code defined in the JSP page or something, cuz... well, they aren't.

  • How to run a jsp file written in a struts framework using tomcat5.0 server

    hi,
    plz somebody help me.
    how do i run a jsp file which i've written in struts framework .
    and anybody plz tell me the process from installing a tomcat server to setting its path such that my jsp page runs....

    hi,
    this is zoya,I gathered from the name that appears in the post header already. :^)
    an engineering student,and i require
    help.
    plz somebody specify the whole process from
    installing tomcat and how to set its path so that i
    can run a jsp page written in struts using tomcatThere are dozens of tutorials on this. First, you need to get Tomcat running without Struts. There are HOW-TO's, sample apps, the whole shebang over at Jakarta's site. Start there. If you get stuck, there are also tutorials on Servlets (and probably Tomcat in specific) on the Net. Do a Google search.
    Next, download Struts. There is, again, extensive HOW-TO and tutorials on their site as well.
    No one will do your work for you. Make an attempt, then post when you are stuck.
    - Saish

  • Relative Path for JSP Files

    I use Liferay Portal. It has a defined directory structure for all portlets and expects files to be in their proper locations. One of these is that it expects all .jsp files to be in the /webroot/html directory.
    The problem is that all references in the struts-config.xml to .jsp files are assumed to be relative to the /html directory. So if, for instance, I set the path as /test/test.jsp then Liferay looks for the file in /html/test/test.jsp. But NitroX requires the full path, including the /html.
    I've gotten this to work on another competing product - in that product I set the Web Root to be the /html directory and it works great. That product allows you to set the path of the struts-config.xml separately. Is there any way to do something similar with NitroX? I tried changing the webroot in the .m7project file manually but it doesn't like it. It seems to insist that the struts-config.xml file is in the webroot.
    Thanks.

    NitroX currently supports only a war directory structure. When a project is created, the Web Application Root directory is computed as the directory containing the WEB-INF folder (which should contain the web.xml file).
    All web app resources (JSP files, image, css files, etc) are expected to be under the Web Application Root directory (at any nested directory level).
    We will enhance this behavior in the future to support arbitrary directory structures.

  • Unable to load the '.jsp' file

    Hi all,
              We use Weblogic 8.1 sp3 and are devloping a struts based application.
              I have deployed my 'ear' file (containing a '.war' and a '.jar' file). We use struts. Our '.war' file, contains the pre-compiled 'jsp' classes (we have changed our web.xml to indicate that we are using pre-compiled jsps. I can show my web.xml file if you need).
              When I click on my 'submit' button, I see that my action class has been invoked and it's spitting out messages to the stdout. Everything looks fine. But, when it is trying to load the '.jsp', I get the following error.
              <b>
              Error 500--Internal Server Error
              javax.servlet.ServletException: [HTTP:101249][ServletContext(id=20736651,name=gta,context-path=/gta)]: Servlet class jsp_servlet._presentation._jsp.__link for servlet /presentation/jsp/Link.jsp could not be loaded because the requested class was not found in the classpath C:\bea\8.1sp3\user_projects\domains\gta\gtaServer\stage\_appsdir_gta_ear\gtaweb.war;C:\bea\8.1sp3\user_projects\domains\gta\.\gtaServer\.wlnotdelete\extract\gtaServer__appsdir_gta_ear_gta\jarfiles\WEB-INF\lib\commons-beanutils20573.jar;C:\bea\8.1sp3\user_projects\domains\gta\.\gtaServer\.wlnotdelete\extract\gtaServer__appsdir_gta_ear_gta\jarfiles\WEB-INF\lib\commons-collections20574.jar;C:\bea\8.1sp3\user_projects\domains\gta\.\gtaServer\.wlnotdelete\extract\gtaServer__appsdir_gta_ear_gta\jarfiles\WEB-INF\lib\commons-digester20575.jar;C:\bea\8.1sp3\user_projects\domains\gta\.\gtaServer\.wlnotdelete\extract\gtaServer__appsdir_gta_ear_gta\jarfiles\WEB-INF\lib\commons-fileupload20576.jar;C:\bea\8.1sp3\user_projects\domains\gta\.\gtaServer\.wlnotdelete\extract\gtaServer__appsdir_gta_ear_gta\jarfiles\WEB-INF\lib\commons-lang20577.jar;C:\bea\8.1sp3\user_projects\domains\gta\.\gtaServer\.wlnotdelete\extract\gtaServer__appsdir_gta_ear_gta\jarfiles\WEB-INF\lib\commons-logging20578.jar;C:\bea\8.1sp3\user_projects\domains\gta\.\gtaServer\.wlnotdelete\extract\gtaServer__appsdir_gta_ear_gta\jarfiles\WEB-INF\lib\commons-validator20579.jar;C:\bea\8.1sp3\user_projects\domains\gta\.\gtaServer\.wlnotdelete\extract\gtaServer__appsdir_gta_ear_gta\jarfiles\WEB-INF\lib\jakarta-oro20580.jar;C:\bea\8.1sp3\user_projects\domains\gta\.\gtaServer\.wlnotdelete\extract\gtaServer__appsdir_gta_ear_gta\jarfiles\WEB-INF\lib\jstl20581.jar;C:\bea\8.1sp3\user_projects\domains\gta\.\gtaServer\.wlnotdelete\extract\gtaServer__appsdir_gta_ear_gta\jarfiles\WEB-INF\lib\standard20582.jar;C:\bea\8.1sp3\user_projects\domains\gta\.\gtaServer\.wlnotdelete\extract\gtaServer__appsdir_gta_ear_gta\jarfiles\WEB-INF\lib\struts20583.jar;C:\bea\8.1sp3\user_projects\domains\gta\.\gtaServer\.wlnotdelete\extract\gtaServer__appsdir_gta_ear_gta\jarfiles\_wl_cls_gen.jar.
              java.lang.ClassNotFoundException: jsp_servlet._presentation._jsp.__link.
                   at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:824)
                   at weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:535)
                   at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:373)
                   at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:463)
                   at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
                   at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:312)
                   at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
                   at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)
                   at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
                   at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:320)
                   at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
                   at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
                   at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
                   at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
                   at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
                   at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:996)
                   at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
                   at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
                   at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6452)
                   at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
                   at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
                   at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3661)
                   at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2630)
                   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
                   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
              </b>
              I have looked in the '.war' file and it contains the above mentioned precompiled class (_link).
              Could anyone point me in the right direction??

    Hi,
              Could you check that whether the jsp file is placed in right place or not ?
              Regards
              Anilkumar kari

  • Unable to retrive the uploaded file in Struts

    hi i am getting error while retrieving the uploaded file in struts. The code is
    struts-config.xml
    ===========
    <form-bean name="GreivanceForm" type="org.apache.struts.validator.DynaValidatorActionForm" >
                   <form-property name="compcode" type="java.lang.String" />
                   <form-property name="complaintName" type="java.lang.String" />
                   <form-property name="category" type="java.lang.String" />
                   <form-property name="subcategory" type="java.lang.String" />
                   <form-property name="priority" type="java.lang.String" />
                   <form-property name="occdate" type="java.lang.String" />
                   <form-property name="occtime" type="java.lang.String" />
                   <form-property name="desc" type="java.lang.String" />
                   <form-property name="comments" type="java.lang.String" />
                   <form-property name="onbehalf" type="java.lang.String"/>
                   <form-property name="employeeId" type="java.lang.String"/>
                   <form-property name="hidSelectedNames" type="java.lang.String"/>
                   <form-property name="individual" type="java.lang.String"/>
                   <form-property name="compOption" type="java.lang.String" />
                   <form-property name="selectedrequestor" type="java.lang.String" />
                   <form-property name="file" type="java.lang.String"/>
              </form-bean>
    <action path="/helpdesk/GrievanceComplaint"
                   type="com.srit.hrnet.helpdesk.grievancemechanism.GrievanceComplaintAction"
                   scope="request" name="GreivanceForm"
                   input=""
                   validate="true"
                   parameter="compOption" >
                   <forward name="success" path="/helpdesk/GrievanceRedressalMechanism/ComplaintDetails.jsp"/>
                   <forward name="showmeetingform" path="/helpdesk/complaint/MeetingDetailsForm.jsp"/>
                   <forward name="transconfirm" path="/helpdesk/GrievanceRedressalMechanism/TransConfirm.jsp"/>
                   <forward name="ViewCompForm" path="/helpdesk/GrievanceRedressalMechanism/ViewCompForm.jsp"/>
              </action>
    and
    Actionclass:
    ========
    * Created on Nov 5, 2004
    * TODO To change the template for this generated file go to
    * Window - Preferences - Java - Code Style - Code Templates
    package com.srit.hrnet.helpdesk.grievancemechanism;
    import java.io.BufferedInputStream;
    import java.io.BufferedOutputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.GregorianCalendar;
    import java.util.List;
    import java.util.StringTokenizer;
    import javax.servlet.ServletException;
    import javax.servlet.ServletOutputStream;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import org.apache.commons.beanutils.BeanUtils;
    import org.apache.struts.action.ActionError;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionMessage;
    import org.apache.struts.action.ActionMessages;
    import org.apache.struts.action.DynaActionForm;
    import org.apache.struts.actions.DispatchAction;
    import org.apache.struts.upload.FormFile;
    import org.apache.struts.validator.DynaValidatorActionForm;
    import org.apache.struts.validator.DynaValidatorForm;
    import com.srit.hrnet.components.SequenceCodeGenerator;
    import com.srit.hrnet.emp.EmployeeGenTO;
    import com.srit.hrnet.emp.courier.CourierMailDAO;
    import com.srit.hrnet.emp.courier.CourierMailTO;
    import com.srit.hrnet.emp.parameter.ParamMasterTO;
    import com.srit.hrnet.helpdesk.SessionValidate;
    import com.srit.hrnet.helpdesk.category.CategoryDAO;
    import com.srit.hrnet.helpdesk.category.CategoryTO;
    import com.srit.hrnet.helpdesk.mails.HDMail;
    import com.srit.hrnet.utilities.DateUtilities;
    import com.srit.hrnet.helpdesk.complaint.TaskDAO;
    import com.srit.hrnet.helpdesk.SessionValidate;
    import com.srit.hrnet.helpdesk.grievancemechanism.GrievanceComplaintForm;
    public class GrievanceComplaintAction extends DispatchAction{
         public ActionForward submitForm(ActionMapping mapping,
                   ActionForm form, HttpServletRequest request,
                   HttpServletResponse response)throws ServletException,IOException {  
                   String msg=null;
                   DynaValidatorActionForm objDyna = (DynaValidatorActionForm)form;
                   GrievanceComplaintDAO gcDao= new GrievanceComplaintDAO();
              ActionForward forward = new ActionForward();
    //          GrievanceComplaintForm gcForm=(GrievanceComplaintForm)form;
                        String CompId = null;
              try
                             SequenceCodeGenerator seq=new SequenceCodeGenerator("GrievanceMechanism");
                             CompId=seq.generateCode();
                   GrievanceComplaintTO gcTO=new GrievanceComplaintTO();
                   System.out.println("Inside GrievanceComplaintAction ......");
                   String CompName=request.getParameter("complaintName");
                   String Category=request.getParameter("category");
                   String prority=request.getParameter("priority");
                   String dateofocc=request.getParameter("occdate");
                   String timeofocc=request.getParameter("occtime");
                   String desc=request.getParameter("desc");
                   String comments=request.getParameter("comments");
    //          String file=request.getParameter("file");
    //          String complaintcode = .generateCode();
                   System.out.println("Inside insert()::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::");
                   System.out.println("Name Of the Complaint name>>>>>>>>>>>>>>"+CompName);
                   System.out.println("Name Of the Categoryt>>>>>>>>>>>>>>"+Category);
                   System.out.println("Name Of the prority>>>>>>>>>>>>>>"+prority);
                   System.out.println("Name Of the dateofocc>>>>>>>>>>>>>>"+dateofocc);
                   System.out.println("Name Of the timeofocc>>>>>>>>>>>>>>"+timeofocc);
                   System.out.println("Name Of the desc>>>>>>>>>>>>>>"+desc);
                   System.out.println("Name Of the comments>>>>>>>>>>>>>>"+comments);
    //          System.out.println("Name Of the file>>>>>>>>>>>>>>"+file);
                   GregorianCalendar occdate=DateUtilities.getGCDateForString(objDyna.getString("occdate"),((com.srit.hrnet.emp.EmployeeGenTO)request.getSession().getAttribute("LoginUser")).getDateFormat(),'/');
                   gcTO.setComplaintCode(CompId);
                   gcTO.setComplaintName(CompName);
                   gcTO.setCategory(Category);
                   gcTO.setPriority(prority);
                   gcTO.setOccdate(occdate);
                   System.out.println("After Setting date in GTO is>>>>>>>>>>>>>>"+gcTO.getOccdate());
                   gcTO.setOcctime(timeofocc);
                   gcTO.setDesc(desc);
                   gcTO.setComments(comments);
                        HDMail mailComp = new HDMail();
                   String errorFlag = null;
                   String filePath = ""+objDyna.get("file");// Attachment path
                   StringTokenizer st=new StringTokenizer(filePath,".");
                   String extension=null;
    //               String filename=null;
                   String attachmentPath = null;
                   while(st.hasMoreTokens())
                        extension=st.nextToken();
    //          while(st1.hasMoreTokens()){
    //               filename=st1.nextToken();
                   System.out.println("Attachment path : "+attachmentPath);
              System.out.println("Extension is.........."+extension);
    //          System.out.println("Name of the file is.............."+filename);
              if(filePath != null && filePath.indexOf(".") != -1 && filePath.length()>=5 ){// If attachment exists
    //               attachmentPath = filePath.substring(filePath.indexOf(".")+1,filePath.length());// file extension
    ////               System.out.println("Attachment path : "+attachmentPath);
                   if(!extension.equalsIgnoreCase("txt") && !extension.equalsIgnoreCase("htm")
                             &&!extension.equalsIgnoreCase("doc") &&!extension.equalsIgnoreCase("rtf")
                                       &&!extension.equalsIgnoreCase("msg") &&!extension.equalsIgnoreCase("oft")
                                       && !extension.equalsIgnoreCase("xls")){
                        errorFlag = "1"; // if the file is not a valid type (not in the above mentioned extensions)
              gcTO.setAttachmentName(filePath);
              if(errorFlag.equals("1")){
    //          String attachmentName = null;
    ////          String attachmentPath = request.getParameter("agendaAttachment");
    //          DynaValidatorForm dyna=(DynaValidatorForm)form;
    //                         FormFile file= (FormFile)objDyna.get("file");
    //                         //dyna.get("file");      
    //          System.out.println("Name of the file after casting....."+file.getFileName());
    //                         if(file!=null && file.getFileName()!=null && !file.getFileName().trim().equals("")){
    //                              String fileName = null;                         
    //                              fileName = file.getFileName();
    //                              attachmentName = fileName;
    //                              if(validFile(fileName))
    //                              writeFile(file,request,fileName);
    //                              else
    //                                   ActionMessages errors=new ActionMessages();
    //                                   errors.add("Err:MsgDesc",new ActionMessage("com.srit.hrnet.helpdesk.complaint.form.fileupload"));                              
    //                                   saveErrors(request,errors);                         
    ////                                   ActionForward map1 = submitSubCategory(mapping,form,request,response);                              
    //                                   resetToken(request);     
    //                                   saveToken(request);
    //                                   return mapping.findForward("ViewCompForm");                              
    //                    int recordexists = gcDao.getComplaint(CompId);
    //                    if(recordexists == 1){
    //                         System.out.println("Calling the update method");
    //                         gcDao.updateComplaintDetails(gcTO);     
    //                    }else{
                        boolean retVal=gcDao.insert(gcTO);
              if (retVal){
                   System.out.println("Record Inserted inside Action.");
                   msg = "<font color='blue'>Record Inserted Successfully .</font>";
                             request.setAttribute("status", msg);
              else{
                   System.out.println("Unable to insert Record inside Action.");
                   msg = "<font color='red'>Unable to insert Record .</font>";
                             request.setAttribute("status", msg);
              else
                   System.out.println("Upload a file of extension(.jpg,.gif,.doc,.htm,.xls,.rtf,oft,msg) inside Action.");
                   msg = "<font color='red'>Upload a file of extension(.jpg,.gif,.doc,.htm,.xls,.rtf,.oft,.msg) </font>";
                             request.setAttribute("status", msg);
              catch (Exception e) {
                   // TODO: handle exception
                   System.out.println("Exception Occurred inside insert action....."+e.getMessage());
                   e.printStackTrace();
    //          else
    //               String insStatus="10";
    //               System.out.println("Accept:Redirecting due to resubmission");
    //               request.setAttribute("transStatus",insStatus);
    //               forward =mapping.findForward("transconfirm");
                   return mapping.findForward("success");
         public boolean validFile(String fileName){
              if(!fileName.equals("")){     
                        int filelength=fileName.length();
                        int sublength= fileName.indexOf('.');
                        String extension = fileName.substring(sublength+1,filelength);
                        if(extension.trim().equalsIgnoreCase("msg") || extension.trim().equalsIgnoreCase("txt") || extension.trim().equalsIgnoreCase("xls") || extension.trim().equalsIgnoreCase("ppt") || extension.trim().equalsIgnoreCase("jpg") || extension.trim().equalsIgnoreCase("gif")|| extension.trim().equalsIgnoreCase("doc" )|| extension.trim().equalsIgnoreCase("pdf") || extension.trim().equalsIgnoreCase("wmv") || extension.trim().equalsIgnoreCase("zip") || extension.trim().equalsIgnoreCase("jpeg") || extension.trim().equalsIgnoreCase("xml") || extension.trim().equalsIgnoreCase("html") ||extension.trim().equalsIgnoreCase("bmp") ||extension.trim().equalsIgnoreCase("htm") ||extension.trim().equalsIgnoreCase("ppt")||extension.trim().equalsIgnoreCase("oft")||extension.trim().equalsIgnoreCase("csv")){
                        return true;
                        }else{
                        return false;
                   return true;
         public int writeFile(FormFile file,HttpServletRequest request,String fileName){
                   int retValue = 0;
                   String size = (file.getFileSize() + " bytes");
                   if(file.getFileSize()>0){
                        //System.out.println("The size of the file is :" + file.getFileSize() + " bytes");
                        String data = null;
                        try {
                             //retrieve the file data
                             String fileTodelete = request.getRealPath("/helpdesk/meetingsagenda/"+fileName);
                             boolean success = (new File(fileTodelete)).delete();
                             //System.out.println("sucess......"+success);          
                             ByteArrayOutputStream baos = new ByteArrayOutputStream();
                             InputStream stream = file.getInputStream();
                             //write the file to the file specified
                             System.out.println("sfsdfkjdsfds "+request.getRealPath("/helpdesk/meetingsagenda/"+fileName));
                             OutputStream bos = new FileOutputStream(request.getRealPath("/helpdesk/meetingsagenda/"+fileName));
                             int bytesRead = 0;
                             byte[] buffer = new byte[8192];
                                  while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
                                       bos.write(buffer, 0, bytesRead);
                             bos.close();
                             data =      "The file has been written to \""+ "/helpdesk/meetingsagenda/"+ "\"";
                             System.out.println("data........."+data);
                                  //close the stream
                             stream.close();
                        }catch(FileNotFoundException fnfe) {
                                  System.out.println("com.srit.hrnet.homepage.fromceo.FromCEOAction.writeFile.Exception :"+ fnfe.toString());
                                  fnfe.printStackTrace();
                                  //retValue = FORMFILE_FILE_NA;
                        }catch(IOException ioe) {
                                  System.out.println("com.srit.hrnet.homepage.fromceo.FromCEOAction.writeFile.Exception :"+ ioe.toString());
                                  ioe.printStackTrace();
                                  //retValue = FORMFILE_ERR_UPD;
                   }//end of try catch:~
                   }else{
                        //The file was a not available
                        //retValue = FORMFILE_SIZE_ZERO;
                   }//end of if else:~
              //     System.out.println("retValue........."+retValue);
                   return retValue;                         
    }//end of ComplaintAction
    and GrievanceFormTO:(Dummy form bean)
    ==========
    * Created on Nov 4, 2004
    * TODO To change the template for this generated file go to
    * Window - Preferences - Java - Code Style - Code Templates
    package com.srit.hrnet.helpdesk.grievancemechanism;
    import java.util.GregorianCalendar;
    import org.apache.struts.upload.FormFile;
    public class GrievanceComplaintTO implements java.io.Serializable {
    private String complaintCode;
    private String compcode; //complaind Id
    private String complaintName;
    private String category;
    private String priority;
    //private GregorianCalendar date;
    private FormFile theFile;
    private String compOption;
    private String desc;
    private String comments;
    private String status;
    private String serviceperson;     //employee who is going to serve the complaint.Applicatble only in case of manual flow.
    private String loggedEmpId; //the employee who has logged the complaint
    private String applyEmpId; //employee to whom the cmplaint belongs to or owner of the complaint
    private String associateComm;
    private String associateRating;
    private GregorianCalendar occdate;
    private String occtime;
    private String attachmentName;
         public String getApplyEmpId() {
              return applyEmpId;
         public void setApplyEmpId(String applyEmpId) {
              this.applyEmpId = applyEmpId;
         public String getAssociateComm() {
              return associateComm;
         public void setAssociateComm(String associateComm) {
              this.associateComm = associateComm;
         public String getAssociateRating() {
              return associateRating;
         public void setAssociateRating(String associateRating) {
              this.associateRating = associateRating;
         public String getCategory() {
              return category;
         public void setCategory(String category) {
              this.category = category;
         public String getComments() {
              return comments;
         public void setComments(String comments) {
              this.comments = comments;
         public String getCompcode() {
              return compcode;
         public void setCompcode(String compcode) {
              this.compcode = compcode;
         public String getComplaintName() {
              return complaintName;
         public void setComplaintName(String complaintName) {
              this.complaintName = complaintName;
         public String getCompOption() {
              return compOption;
         public void setCompOption(String compOption) {
              this.compOption = compOption;
         public String getDesc() {
              return desc;
         public void setDesc(String desc) {
              this.desc = desc;
         public String getLoggedEmpId() {
              return loggedEmpId;
         public void setLoggedEmpId(String loggedEmpId) {
              this.loggedEmpId = loggedEmpId;
         public String getOcctime() {
              return occtime;
         public void setOcctime(String occtime) {
              this.occtime = occtime;
         public String getPriority() {
              return priority;
         public void setPriority(String priority) {
              this.priority = priority;
         public String getServiceperson() {
              return serviceperson;
         public void setServiceperson(String serviceperson) {
              this.serviceperson = serviceperson;
         public String getStatus() {
              return status;
         public void setStatus(String status) {
              this.status = status;
         public String getComplaintCode() {
              return complaintCode;
         public void setComplaintCode(String complaintCode) {
              this.complaintCode = complaintCode;
         public void setOccdate(GregorianCalendar occdate) {
              this.occdate = occdate;
         public GregorianCalendar getOccdate() {
              return occdate;
         public String getAttachmentName() {
              return attachmentName;
         public void setAttachmentName(String attachmentName) {
              this.attachmentName = attachmentName;
         public FormFile getTheFile() {
              return theFile;
         public void setTheFile(FormFile theFile) {
              this.theFile = theFile;
    but i am getting error
    javax.servlet.ServletException: BeanUtils.populate
         org.apache.struts.util.RequestUtils.populate(RequestUtils.java:497)
         org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:798)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:205)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
         org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         com.srit.hrnet.filter.SessionValidateFilter.doFilter(SessionValidateFilter.java:81)
    root cause
    org.apache.commons.beanutils.ConversionException: Cannot assign value of type 'org.apache.struts.upload.CommonsMultipartRequestHandler$CommonsFormFile' to property 'file' of type 'java.lang.String'
         org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:424)
         org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:1733)
         org.apache.commons.beanutils.PropertyUtilsBean.setNestedProperty(PropertyUtilsBean.java:1648)
         org.apache.commons.beanutils.PropertyUtilsBean.setProperty(PropertyUtilsBean.java:1677)
         org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1022)
         org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811)
         org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:298)
         org.apache.struts.util.RequestUtils.populate(RequestUtils.java:495)
         org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:798)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:205)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
         org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         com.srit.hrnet.filter.SessionValidateFilter.doFilter(SessionValidateFilter.java:81)
    and my jsp is:
    =========
    <%@ page language="java" %>
    <%@ taglib uri="struts-bean" prefix="bean" %>
    <%@ taglib uri="struts-html" prefix="html" %>
    <%@ taglib uri="struts-logic" prefix="logic" %>
    <%@ taglib uri="TabGenerator" prefix="GenerateTab" %>
    <%@ page import="com.srit.hrnet.utilities.DateUtilities"%>
    <%@ page import="com.srit.hrnet.components.BasicDAOConstants" %>
    <%@ taglib uri="AccessLogin" prefix="GeneralAccess" %>
    <%@ taglib uri="iterateTag" prefix="iterateTag" %>
    <%@ page import="com.srit.hrnet.components.BasicDAOConstants,com.srit.hrnet.emp.EmployeeGenTO,com.srit.hrnet.helpdesk.grievancemechanism.*"%>
    <%@ page import="com.srit.hrnet.tags.*"%>
    <html:html locale="true">
    <HEAD>
         <TITLE>
                   <bean:message key="com.srit.hrnet.helpdesk.complaint.form.title"/>
         </TITLE>
         <META NAME="Generator" CONTENT="EditPlus">
         <META NAME="Author" CONTENT="">
         <META NAME="Keywords" CONTENT="">
         <META NAME="Description" CONTENT="">
    <link rel="stylesheet" type="text/css" href="<%= (session.getAttribute("LoginUser") != null ?
                             ((com.srit.hrnet.emp.EmployeeGenTO)session.getAttribute("LoginUser")).getEmpPageStyleSheet() :
                             com.srit.hrnet.components.access.AccessCodes.GLOBAL_STYLESHEET)%>">
    <script language="javaScript" src="<%= request.getContextPath()%>/jscript/GlobalValidationScript.js" purpose="include"></script>
    <%      
    int dateFormat = (session.getAttribute("LoginUser") != null ? ((com.srit.hrnet.emp.EmployeeGenTO)session.getAttribute("LoginUser")).getDateFormat() : 2);
         System.out.println("/reports/training/TRngBaseReport dateFormat = "+dateFormat);
         /* *** get the current date *** */
         java.util.GregorianCalendar gc1 = new java.util.GregorianCalendar();
         int yy = gc1.get(java.util.Calendar.YEAR);
         int mm = gc1.get(java.util.Calendar.MONTH);
         int dd = gc1.get(java.util.Calendar.DATE);     
         mm = mm + 1;
         String mon;
         String day;
         if(dd <= 9)
              day = "0" + java.lang.String.valueOf(dd);
         else
              day = java.lang.String.valueOf(dd);
         if(mm <= 9)
              mon = "0" + java.lang.String.valueOf(mm);
         else
              mon = java.lang.String.valueOf(mm);
         java.lang.String currentDate = "";
         if(dateFormat == 3){
              currentDate = java.lang.String.valueOf(yy+"/"+mon+"/"+day);/* (yyy-mm-dd format) */
         }else if(dateFormat == 1){
              currentDate = java.lang.String.valueOf(mon+"/"+day+"/"+yy);/* (mm-dd-yyy format) */
         }else if(dateFormat == 2){
              currentDate = java.lang.String.valueOf(day+"/"+mon+"/"+yy);/* (dd-mm-yyy format) */
         System.out.println("/reports/training/TRngBaseReport currentDate = "+currentDate);
    %>
    <script language="javaScript" src="<%= (session.getAttribute("LoginUser")!=null ? ((com.srit.hrnet.emp.EmployeeGenTO)session.getAttribute("LoginUser")).getScriptFile() : "")%>" purpose="include"></script>
    <script language="javaScript" src="jscript/CommonDialog.js" purpose="include"></script>
    <script language="javaScript" src="jscript/GlobalValidationScript.js"></script>
    <script language="javascript">
         var gNow = new Date("<%=currentDate%>");
         function val_complaint()
    if(document.GreivanceForm.complaintName.value.length==0)
         alert("Enter Complaint Name");
         document.GreivanceForm.complaintName.focus();
         return false;
    if(document.GreivanceForm.category.value =='NA')
         alert("select category");
         document.GreivanceForm.category.focus();
         return false;
    if(document.GreivanceForm.priority.value == 'NA')
         alert("select priority");
         document.GreivanceForm.priority.focus();
         return false;
         if(document.GreivanceForm.occdate.value == "")
              alert("Enter Date (dd/mm/yy)");
              document.GreivanceForm.occdate.focus();
              return false;
         else     
         if(document.GreivanceForm.occdate.value>document.GreivanceForm.currentDate.value){
                   alert("select Previous or Current date");
                   document.GreivanceForm.occdate.focus();
                   return false;
         if(document.GreivanceForm.occtime.value == "")
         alert("Select Time of Occurence.");
         document.GreivanceForm.occtime.focus();
         return false;
    else
    if(!IsValidTime(document.GreivanceForm.occtime.value) )
    alert("Enter Valid Time (HH:MM)");
              return false;
         if(document.GreivanceForm.desc.value == "")
         alert("Enter Description");
         document.GreivanceForm.desc.focus();
         return false;
              document.forms[0].compOption.value='submitForm';
              document.forms[0].submit();
              return false;
         function IsValidTime(givenTime)
              var hour = 0;
              var minute = 0;
              var timePat = /^(\d{1,2}):(\d{1,2})?$/;
              var matchArray = givenTime.match(timePat);
              if (matchArray == null)
                   alert("Enter Valid Time.");
                   return false;
              hour = matchArray[1];
              minute = matchArray[2];
              if(hour==0 && minute==0)
              alert("The Time You Entered is 0:0");
              return false;
              if (hour < 0 || hour > 23)
              alert("Hour must be between 0 and 23");
              return false;
              if (minute<0 || minute > 59)
              alert ("Minute must be between 0 and 59.");
              return false;
              return true;
    unction help(url)
         var attributes = 'menubar=no,toolbar=no,location=no,width=625,height=375,resizable=yes';
         var name = 'Help';
         window.open(url,name,attributes);
    //return false;
    </script>
    <script language = "javaScript" src = "<%=request.getContextPath()%>/jscript/CommonDialog.js" purpose = "include"></script>
    </HEAD>
    <body bgcolor="#FFFFFF" onload="setFocus()">
    <GenerateTab:displaytabs tabId="<%=com.srit.hrnet.masters.gui.GUIConstants.HD_GRIEVANCE_REDRESSAL_FORM%>" activeSubTab="0" >
    <table align="right">
              <tr>
                   <td>
                        <img src="<%=request.getContextPath()%>/images/help.gif" border="0" alt="Help">
                   </td>     
              </tr>     
         </table>
         <html:form action="/helpdesk/GrievanceComplaint" enctype="multipart/form-data" method="POST" onsubmit="javascript:return val_complaint()">
         <html:hidden property="compOption" value="submitForm" />
         <html:hidden property="onbehalf"/>
         <html:hidden property="employeeId"/>
         <html:hidden property="hidSelectedNames"/>
         <html:hidden property="selectedrequestor"/>
         <html:hidden property="individual"/>
         <table cellpadding="3" cellspacing="0" align="center" >
              <th align="center" class="tablehead" colspan="2">
              <b> Complaint Form </b>
              </th>
    <tr>
                   <td colspan="1" class='tablesubhead'>
                   <b><bean:message key="com.srit.hrnet.helpdesk.redressal.form.complaintname"/></b><font class="star"> *</font>
                   </td>
                   <td class='subhead'>
                   <html:text property="complaintName" maxlength="99"/>
                   </td>
              </tr>
         <tr>
                   <td class='tablesubhead' colspan="1"><b><bean:message key="com.srit.hrnet.helpdesk.redressal.form.category"/></b>
                   <font class="star">*</font></td>
                        <td class="tableright" property="category" >
                        <iterateTag:iterate propertyName='<%=IterateInterface.ITERATE_HELPDESK_GRIEVANCE_CATEGORY%>' defaultSelected='<%=request.getAttribute("category")==null?null:""+request.getAttribute("category")%>' selectSize='<%=100%>' tabInd='<%="3"%>'>
                        </iterateTag:iterate>
                   </td>
              </tr>
              <tr>
                   <td class='tablesubhead' colspan="1"><b><bean:message key="com.srit.hrnet.helpdesk.redressal.form.priority"/></b>
                   <font class="star">*</font></td>
                   <td class="subhead">
                        <iterateTag:iterate propertyName='<%=IterateInterface.ITERATE_HELPDESK_GRIEVANCE_PRIORITY%>' defaultSelected='<%=request.getAttribute("priority")==null?null:""+request.getAttribute("priority")%>' selectSize='<%=100%>' tabInd='<%="3"%>'>
                                  </iterateTag:iterate>
                   </td>
         </tr>
         <tr>
                             <td class='tablesubhead' colspan=1><b>Date of Occurence</b>
                             <font class="star">*</font> </td>
                             <td class="subhead">     
                             <html:text name="GreivanceForm" property="occdate" maxlength="10"/>
                             <input type="hidden" name="currDate" />
                             <img src="<%= request.getContextPath()%>/images/calendar.jpg" border="0" alt="Calendar" >
                             </td>                         
                   </tr>
                                  <tr>
                                       <td class='tablesubhead' colspan=1><b>Time of Occurence</b>
                                       <font class="star">*</font></td>
                                       <td class="subhead">     
                                       <html:text name="GreivanceForm" property="occtime" maxlength="10"/> (24 Hrs format)</td>
                             </tr>
                             <tr>
                        <td class="tablesubhead" colspan=1>
                             <b>Description</b>
                             <font class="star">*</font></td>
                                       <td class="subhead">
                                       <html:textarea property="desc" styleClass="formObject" cols="40" rows="4"></html:textarea>
                                       </td>
                        </tr>
                   <tr>
              <td class="tablesubhead" colspan=1>
                   <b>Comments/Suggestions</b>
              </td>
                             <td class="subhead">
                             <html:textarea property="comments" styleClass="formObject" value="" cols="40" rows="4"></html:textarea>
                             </td>
                   </tr>
                   <tr>
                   <td class="tableleft">
              <b><bean:message key="com.srit.hrnet.helpdesk.redressal.form.attachment"/> </b>
                                  </td>
                             <td class="tableright">
                                  <html:file property="file" size="18" />
                             </td>
              </tr>
                   <tr>
                   <td colspan="2" align="center" class="tablesubhead">
                   <input type="submit" class="submit" value="Submit" >
                    <html:reset property="reset" styleClass="submit" />
                   </td>
              </tr>
    </table>
         <input type="hidden" name="currentDate" value="<%=currentDate%>">
    </html:form>
    </GenerateTab:displaytabs>
    <html:javascript formName="/SubmitComplaint"/>
    </body>
    </html:html>
    please help me..

    VAS_MS wrote:
    please help me..First help yourself by posting a clear question
    You have far to much code posted and without the use of the correct code tags its almost unreadable.
    You have a question about uplaoding files with Struts then get rid of all the junk in your code thats not related to uploading files.
    If you have an error then post the relevant information on the error
    like
    org.apache.commons.beanutils.ConversionException:
    Cannot assign value of type 'org.apache.struts.upload.CommonsMultipartRequestHandler$CommonsFormFile' to property 'file' of type 'java.lang.String'
    org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:424)If you had posted only that you would have given enough information, that error says it all you are trying to put your file into a String and its not working.
    reread the tutorial/documentation provided and try again
    Edited by: pgeuens on 21-mrt-2008 8:04

  • Questions regarding jsp file download from blob

    Hi developers, i'm doing jsp file download from a blob column in DB2 using struts,
    1) How do i design the jsp page such that the page will show perhaps a hyperlink for me to download the file?
    2) What about struts-config.xml? Do i need to modify any mappings there?
    It would be great if some kind developers were to provide some sample codes for me. Thanks alot. Your effort is kindly appreciated.

    http://kr.forums.oracle.com/forums/thread.jspa?threadID=1982213 - looks similar, you may need to change contentType as per use case

  • Error in jsp file

    I am facing some issue with the jsp using strut 2.1.8.1
    My Jsp code is
    <%@ page language="java"  pageEncoding="ISO-8859-1"%>  
    <%@ taglib prefix="html" uri="/struts-tags" %>  
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
    <html>  
    <head>  
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">  
    <title>Onstar Forumz</title>  
    </head>  
    <body bgcolor="#FFFFFF" text="#000000">  
    <%@ include file="/header.jsp" %>  
    <html:form action="UserverifyAction" name="userForm" type="com.onstar.user.in.form.UserForm">  
    <html:text property="username" style="position:absolute;left:720px;top:271px;width:112px;font-family:Arial;font-size:16px;z-index:15" name="username" value="" ></html:text>  
    <html:password property="password" style="position:absolute;left:720px;top:302px;width:112px;font-family:Arial;font-size:16px;z-index:16" name="password" value="" ></html:password>  
    <div id="wb_Username" style="position:absolute;left:631px;top:276px;width:82px;height:16px;z-index:17;" align="left">  
    <font style="font-size:13px" color="#FFFFFF" face="Arial"><b>User name :</b></font></div>  
    <div id="wb_Password" style="position:absolute;left:631px;top:307px;width:82px;height:16px;z-index:18;" align="left">  
    <font style="font-size:13px" color="#FFFFFF" face="Arial"><b>Password   : </b></font></div>  
    <div id="wb_signin" style="position:absolute;left:843px;top:304px;width:101px;height:23px;z-index:19;" align="left">  
    <input type="image" src="images/gold_sign.gif" id="signin" alt="" align="top" border="0" style="width:101px;height:23px;"></div>  
    </html:form>  
    <%@ include file="/footer.jsp" %>  
    </body>  
    </html>Error Message:
    org.apache.jasper.JasperException: /index.jsp(15,0) Attribute property invalid for tag text according to TLD index.jsp is the name of the jsp file.
    I have placed the struts2-core-2.1.8.1.jar in lib folder as well as well I have configured the buildpath with the jar file(struts2-core-2.1.8.1.jar)
    Please help me...Thanks in Advance{                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    I think we have a case here of trying to use the Struts1.2 tag libraries in Struts2.0
    The tag libraries are quite different :-)
    I believe the <s:textfield> tag is probably what was intended here?
    Or install struts 1.2 instead of struts2 :-)

  • Image displays in some jsp files but not others

    OK, I have a jsf jsp pages js tag for my application that occurs in several jsp pages:
    <tr>
       <td>
          <jsp:include page="/includes/footer.jsp"/>
       </td>
    </tr>     footer.jsp has an image tag like this:
    <td align="left"><img src="images/logo.jpg" alt="X Systems"/></td>     The jsp files are in a directory which is under the base directory like the include and image files. For some reason, in one jsp page the logo.jpg file does not get displayed. As I understand it, the application server jboss/tomcat resolves the image files. Why would it be displayed it in one page and not another?

    You are using a relative link to access your image.
    That means it will look for your image relative to the page it last served.
    If you ask for http://myapp/root.jsp, it will locate http://myapp/images/logo.jsp
    If you ask for http://myapp/module/index.jsp it will locate http://myapp/module/images/logo.jsp
    If you right click on your image / broken image placeholder and look at its properties, you should be able to see the url which it is trying to fetch the image from.
    The client will resolve relative links from the address url it last accessed. It knows nothing of any serverside forwards/includes that you might have done.
    So if you access http://myapp/action and forward to /moduel/accounting/balanceSheet.jsp it will still treat the url as http://myapp/action for resolving relative links.
    As far as the client is concerned, the root is /
    As far as your web application is concerned, the root is /myapp (or whatever your context name is)
    Because of this you can't give your images an static absolute url, because you would be hardcoding the context name into your jsp.
    Alternatives
    - use something like <img src="<%= request.getContextName() %>/images/logo.jsp"/>
    - use a tag library to hide the implementation of option #1 (like struts tag html:img)
    - only use relative links, and always specify a html <base> on your page to resolve relative links from.
    Hope this helps,
    evnafets

  • Problem in executing a JSP file that includes a Custm tag

    Hi,
    I am very new to JSP,especially custom tags. I tried to run my first custom tag program but i cud not succeed.
    I tried to run it using Tomcat as well J2ee1.3. But still cud not c the output.
    I have placed jsp file,TLD etc in Web inf of root dir and class file inside classes folder..but i got some error saying tag with prefix not found in the tag library...
    i tried in all the ways but all in vain... I will post my code and exact error i faced.. can anyone help me soon to see the output?
    WelcomCtag.java
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    public class WelcomeCtag extends TagSupport
         private String Name=null;
         public String getName()
              return Name;
         public int doStartTag()
              try
                   JspWriter output=pageContext.getOut();
                   output.println("Welcome" + getName());
              }catch(Exception e)
                   throw new Error("Encountered an errer");
              return SKIP_BODY;
         public int doEndTag()
              try{}
              catch(Exception e)
                   throw new Error("Encountered an errer");
              finally
                   return SKIP_PAGE;
    [u]example.tld[/u]
    <taglib>
         <tlibversion>1.0</tlibversion>
         <jspversion>1.1</jspversion>
         <shortname>example</shortname>
         <info> A small example for usage of the tag library</info>
         <tag>
              <name> Welcome></name>
              <tagclass>WelcomeCtag</tagclass>
         <bodycontent>empty</bodycontent>
         <info>This tag is an example to display a welcome message</info>
         <attribute>
              <name>Name</name>
              <required>true</required>
              <rtexprvalue>true</rtexprvalue>
         </attribute>
         </tag>
    </taglib>
    [u]WelcomeCustomtag.jsp[/u]
    <%@ taglib prefix="example" uri="./example.tld" %>
    <html>
    <title>Welcome Handler</title>
    </head>
    <body>
    <example: Welcome Name="Panduranga"/>
    </body>
    </html>
    and the error i get while executing is here..........
    org.apache.jasper.JasperException: /WelcomeCustomtag.jsp(6,0) No tag "" defined in tag library imported with prefix "example"
         org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
         org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
         org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:196)
         org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1308)
         org.apache.jasper.compiler.Parser.parseElements(Parser.java:1564)
         org.apache.jasper.compiler.Parser.parse(Parser.java:126)
         org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)
         org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
         org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:146)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    when i referred some other tutorials some have stored the tld file inside a folder called tags inside web inf and they have used like this <tags:example> etc and it wrked but if i want to specify some attributes i dunno how to give using <tags> style....
    Can anyone help me n tell me the difference in using tag like this <eample> and <tags: example> like this.....
    Thanks,
    Akshatha                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    1.
    Multiple tlds in web.xml
    Have multiple taglib elements in your web.xml - see below.
    <jsp-config>
      <taglib>
         <taglib-uri>http://example/taglib</taglib-uri>
         <taglib-location>/WEB-INF/example.tld</taglib-location>
      </taglib>
       <taglib>
          <taglib-uri>http://anotherexample/taglib</taglib-uri>
           <taglib-location>/WEB-INF/anotherexample.tld</taglib-location>
       </taglib>
    </jsp-config>The jsp-config element should be just after the servlet-mapping element in servlet 2.3 spec.
    For 2.4 spec, you can put it anywhere.
    In your jsp, to use the tags from the two tag libraries, use 2 taglib directives
    <%@ taglib prefix="example" uri="http://example/taglib" %>
    <%@ taglib prefix="anotherexample" uri="http://anotherexample/taglib" %>
    <example:tag1.................>
    <anotherexample:tag2.................> etc2.
    Mutliple tags per tld
    Have multiple <tag> elements in your tld.
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
    <taglib>
       <tlib-version>1.0</tlib-version>
       <jsp-version>1.2</jsp-version>
       <short-name>j2ee</short-name>
       <tag>
          <name>tagName</name>
          <tag-class>pkgName.classname</tag-class>
          <body-content>JSP</body-content>
          <display-name>OverlapTag</display-name>
          <attribute>
             <name>attr1</name>
             <required>false</required>
             <rtexprvalue>true</rtexprvalue>
          </attribute>
          <attribute>
             <name>attr2</name>
             <required>false</required>
             <rtexprvalue>true</rtexprvalue>
          </attribute>
       </tag>
       <tag>
          <name>tag_2_Name</name>
          <tag-class>pkgName.classname</tag-class>
          <body-content>JSP</body-content>
          <display-name></display-name>
          <attribute>
             <name>attr1_2</name>
             <required>false</required>
             <rtexprvalue>true</rtexprvalue>
          </attribute>
          <attribute>
             <name>attr2_2</name>
             <required>false</required>
             <rtexprvalue>true</rtexprvalue>
          </attribute>
       </tag>
    </taglib>
    Interesting snippet
    If you are using a 3rd party tag library, then the tags would come packaged in a jar file. The MTEA-INF directory of the jar file would contain the tlds and the tld would have an uri element. You can use it directly in the jsp without declaring the tld file in web.xml provided the jar file is in your classpath.
    For example, take the struts tag libraries, say the logic tags.
    The struts.jar contains, among other things, the tag class files and the tld files (inside /META-INF/tlds)
    All you have to do is put Struts.jar in the classpath (easy way to do this is put it in the WEB-INF/lib directory of your web-application).
    The jar file has struts-logic-1.1.tld in the META-INF/tlds directory.
    This tld file looks like this
    <taglib>
    <tlibversion>1.2</tlibversion>
    <jspversion>1.1</jspversion>
    <shortname>logic</shortname>
    <uri>http://jakarta.apache.org/struts/tags-logic</uri>
    ..................Now to use the tags in your jsp, you dont require the tld mappings in web.xml using the uri above in the taglib directive in your jsp
    <%@ taglib prefix="example" uri="http://jakarta.apache.org/struts/tags-logic" %> cool, right ? :)
    This is how you should pkg your own tags too. The tag classes have to be jarred and the tlds should go into the META-INF of the jar so that other users can simply add the jar to the cp and start using your tags.
    cheers,
    ram.

  • Problem compiling jsp file

    I am using ant to precompile my jsp files which contains struts taglibs but it is giving an error
    [jasperc] error:org.apache.jasper.JasperException: Error compiling \attendance\AllPendingAuthentication.jsp
    [jasperc] at org.apache.jasper.JspC.processFile(JspC.java:543)
    [jasperc] at org.apache.jasper.JspC.execute(JspC.java:748)
    [jasperc] at org.apache.jasper.JspC.main(JspC.java:770)
    what i need to do to come out of this??

    You can load the JSP in the browser and add a jsp_precompile parameter, something like:
    http://yourwebsite.com/yourwebpage.jsp?jsp_precompile
    Any mistakes will end up being displayed in the browser, but the JSP will never get executed should it contain no programming mistakes.

  • URGENT: Is it possible to upload multiple files using STRUTS

    Hi,
    Is it possible to upload multiple files using STRUTS.
    I am able to upload a single file. But how do i upload multiple files ??
    upload.jsp
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <html:html>
    <head>
    <title>New Page 1</title>
    </head>
    <body>
    <html:form action="/secure/uploadFile.do" enctype="multipart/form-data" method="POST" type="com.smartstream.webconnect.user.actions.UploadActionForm">
    <p>File to upload
    <html:file property="fileUpload" size="20"/></p>
    <p><html:submit/></p>
    </html:form>
    </body>
    </html:html>
    UploadAction.java
    public class UploadAction extends BaseAction {
        Logger log = Logger.getLogger(AttachMessageAction.class);
        public ActionForward executeAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ActionException {
            System.out.println("executeAction of UploadAction");
            UploadActionForm uploadActionForm = (UploadActionForm) form;
            int fileSize = uploadActionForm.getFileUpload().getFileSize();
            System.out.println("uploadActionForm.getFileUpload().getFileSize() = " + uploadActionForm.getFileUpload().getFileSize());
            byte buffer[] = new byte[1024];
            try {
                BufferedInputStream bufferedInputStream = new BufferedInputStream(uploadActionForm.getFileUpload().getInputStream());
                FileOutputStream fos = new FileOutputStream("s:\\uploaded\\" + uploadActionForm.getFileUpload().getFileName());
                int read;
                while ( (read = bufferedInputStream.read(buffer,0,buffer.length)) != -1) {
                    fos.write(buffer, 0, read);
                fos.flush();
                fos.close();
                bufferedInputStream.close();
                return mapping.findForward("success");
            } catch (IOException e) {
                e.printStackTrace();
                return mapping.findForward("error");
            }catch(OutOfMemoryError o){
                o.printStackTrace();
                System.out.println("o.getMessage() " + o.getMessage());
                return mapping.findForward("error");
    UploadActionForm.java
    public class UploadActionForm extends ActionForm{
        private FormFile fileUpload;
        private byte[] fileContent;
        public FormFile getFileUpload() {
            org.apache.struts.taglib.html.FormTag _jspx_th_html_form_0;
            return fileUpload;
        public byte[] getFileContent() {
            return fileContent;
        public void setFileUpload(FormFile fileUpload) {
            this.fileUpload = fileUpload;
        public void setFileContent(byte[] fileContent) {
            this.fileContent = fileContent;
    }--Bhupendra Mahajan

    Yes, you could try using the multipart handler...
    But I have a better idea...
    Determine the maximum number of file uploads that the
    user can do at one time. I mean, you can't
    realistically have the user upload a million files at
    one time. So say the max is 20. So you create your
    action form class with 20 FormFile fields called file1
    to file20.
    Then when you dynamically create your page, you
    dynamically create the specified number of file fields
    and 1 hidden field called "totalFiles" which contains
    the number of file fields you created. This should be
    an int field in the form bean.
    Then when you do your action processing, you just loop
    thru the totalFiles... Or well, actually, you may not
    need that at all. You could just check all the
    FormFile fields and whatever ones aren't null contain
    files.But what about UploadActionForm.java[b]
    How do i have exact mapping of the HTML form in this file ??
    --[b]Bhupendra Mahajan

  • Parsing of JSP file

    Parsing of JSP File '/main.jsp' failed:
    /main.jsp(1): Could not parse deployment descriptor: java.io.IOException: cannot resolve 'http://java.sun.com/jstl/core' into a valid tag library
    probably occurred due to an error in /main.jsp line 1:
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    Sun May 06 18:27:39 GMT+05:30 2007
    I got this error when i deployed my application through weblogic...
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    I think its because of this line..can someone help me..its urgent

    /Username.jsp(3): Error in using tag library          > y uri='/WEB-INF/struts-html.tld' prefix='html':
              > cannot find tag class:
              > 'org.apache.struts.taglib.html.BaseTag'
              > probably occurred due to an error in /Username.jsp
              > line 3:
              > <%@ taglib uri="/WEB-INF/struts-html.tld"
              > prefix="html" %>
              Ok, we can tell that the JSP compiler was able to read and parse the TLD file, because it refers to a class name specified in the TLD. That's a good sign. However, after it found the class name, it wasn't able to find the actual class file. You'll need to ensure that the "struts.jar" file is in your "WEB-INF/lib" directory of the application.
              If you already have that, or it still doesn't work when you redeploy it with this, then it's possible there is a conflict with another "struts.jar" in the web application classloader context. If that other "struts.jar" is not controlled by you, but is instead controlled by WebLogic, then you may have to specify the "<prefer-web-inf-classes>" element (to specify a "true" value), which will make the web application classloader prefer classes and jars in your WEB-INF directory over classes found elsewhere.

Maybe you are looking for

  • Transporting user defined selection screen from one server to another

    How to transport a user defined selection screen (0100) from one server to another. PBO and PAI modules written in PBO and PAI events for the selection screen are not transported. How to transport the modules in the events for the selection screen.

  • Ripping Audiobooks to iTunes

    I am finding copying audiobooks to iTunes and then into my iPod to be rather confusing and not terribly intuitive. I am trying to copy audiobooks borrowed from the library to iTunes and then to my iPod for listening to on long drives cross country. I

  • Flash 5.5 cursor disappears on iPad

    Hello: I just upgraded to Flash 5.5. When I compile for iOS my cursor disappears. I'm using the following code. It worked great when I compiled it on 5.0 but it stopped working with 5.5. Please help. player3.x = stage.mouseX; player3.y = stage.mouseY

  • SAPScript: Box Problem??

    Hi all, I need a dynamic box size on Main Window, here are the conditions if I Script layout output is going Beyond one page then I need BOX1 on Main Window, otherwise, if output is limited to one page then BOX2. Here i am trying to display line item

  • No. of Transactions Per Sec.

    Hi, Please let me know the various constraints relating to transaction rate that an Oracle Server on WINNT or Solaris can support. Basically I would like to know its dependency on the Memory available, CPU speed, Table Size, no of sql statements in a