javascriptvalidationjspstrutsoc4j

Jsp page showing source code instead of result


I am trying to display a page in struts but when I ran it in OC4J server it is showing src code also along with my page. here is my JSP.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 <%@ page import="java.util.*"%>

 <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
 <%@ taglib uri="/WEB-INF/displaytag.tld" prefix="display"%>
 <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>

 <%
    response.setHeader("Cache-Control","no-store"); //HTTP 1.1
    response.setHeader("Pragma","no-cache"); //HTTP 1.0
    response.setDateHeader ("Expires", 0); //prevents caching at the proxy 
 %>
 <html xmlns="http://www.w3.org/1999/xhtml">

 <%
    java.util.Calendar currentDate =java.util.Calendar.getInstance();
    java.text.SimpleDateFormat formatter= 
    new java.text.SimpleDateFormat("dd-MMM-yy@HH:mm");
    String dateNow=formatter.format(currentDate.getTime());   

    String username=(String)request.getSession().getAttribute("CUserID");

    if(username==null) username="";

    ArrayList levyPayRpt=(ArrayList)request.getAttribute("citylist");
    request.getSession().setAttribute("citylist",levyPayRpt);
    int citylist;

    if(levyPayRpt==null) {
       citylist=0;
    } else {
       citylist=levyPayRpt.size();
    }    

  %>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
  <title>Companies By Region/Sectors</title>
  <link href="css/displaytagex.css" rel="stylesheet" type="text/css" / >
  <link href="css/boto.css" rel="stylesheet" type="text/css" / >

  <script language="javascript" type="text/javascript" src="js/datetimepicker.js"></script>
  <link rel="stylesheet" type="text/css" media="all" href="js/skins/aqua/theme.css" title="Aqua" />
  <script language="javascript" type="text/javascript" src="js/datetimepicker.js"></script>
  <script language="javascript" type="text/javascript" src="js/menu_home.js"></script>
  <script language="javascript" type="text/javascript" src="js/RegisterCategory.js"></script>
  <script type="text/javascript" src="js/calendar_inc.js"></script>
  <script type="text/javascript" src="js/calendar.js"></script>
  <script type="text/javascript" src="js/lang/calendar-en.js"></script>
  <script language="javascript" type="text/javascript" src="js/VTFSCommon.js"></script>
 </head>
  <body onload="loading();">
       <html:form action="/LevyPayersByRegionAction.do?methodToCall=getCompByRegion" method="post" >

        <html:javascript formName="LevyPayersByRegion" />

        <table width="100%" border="0" cellspacing="0" cellpadding="1">
          <tr>
            <td valign="top" class="head_bgcolor">Claims By Region/Sector</td>
          </tr>
          <tr>
            <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td valign="top" class="padding5px"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td valign="top"><table border="0" class="details_table" cellspacing="0" cellpadding="0">
                          <tr>
                            <td>Parameters</td>
                          </tr>
                      </table></td>
                    </tr>
                    <tr>
                      <td valign="top"><table class="field_table" width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                  <td style="height:50px;"><table width="100%" border="0" cellspacing="0" cellpadding="3">

                                    <tr>

                                  <td width="11%">From Date:<span class="red12">*</span>

                                                        <html:text property="FDate" name="LevyPayersByRegion" style="width:110px;hight:14px"  readonly="true"/>
                                        <a><img alt="pick a date" align="Center" width="20" height="21" src="images/cal.JPG"  onclick="return showCalendar('FDate','0','%d-%b-%Y',false,false);" class="cursorHand"></img></a>
                                      </td>
                                        <td width="11%">To Date:<span class="red12">*</span>
                                        <html:text property="TDate" name="LevyPayersByRegion" style="width:110px;hight:14px" readonly="true"/>
                                       <a><img alt="pick a date" align="Center" width="20" height="21" src="images/cal.JPG"  onclick="return showCalendar('TDate','0','%d-%b-%Y',false,false);" class="cursorHand"></img></a>
                                              </td>  </tr>
                                              <tr>
                                  <td align="right">Region&nbsp; :<span class="red12">*</span></td>
                               <td>   <html:select property="regionName"
                                               name="LevyPayersByRegion"  style="width:300px;" >
                                                            <html:option value="">-----------------Select--------------------</html:option>
                                                           <html:options name="citylist" />



                                                            </html:select></td></tr>
             <tr>
                                  <td align="right">
                                      Company Sector&nbsp; :
                                      <span class="red12">
                                        *
                                      </span>
                                  </td><td>    <html:select property="sectorName"
                                               name="LevyPayersByRegion"  style="width:300px;" >
                                                            <html:option value="">-----------------Select--------------------</html:option>
                                                           <html:options name="sectorlist" />



                                                            </html:select></td></tr>        


                                              <td>&nbsp;</td>                                             
                                     <!--    <td><a href="#"><img src="images/list_img.jpg" border="0" /></a></td> -->
                                     <!--    NewCal([textbox id],[date format],[show time in calendar?],[time mode (12,24)?])-->

                                        </table></td>
                                      </tr>
                                  </table>
                                  </td>
                                </tr>
                                <tr>
                                  <td class="bordertop">
                                  <table width="100%" border="0" cellspacing="0" cellpadding="3">
                                      <tr>
                                        <td class="mandatory">* Mandatory Field</td>
                                        <td>
                                            <html:button property="sss" value="Generate" onclick="generateClicked();"  />

                                              <html:button property="btnClear"
                                                                       value="Clear" onclick="clearClicked();" />
                                         <html:hidden name="LevyPayersByRegion" property="hidMode"/>
                                             <input type="hidden" name="mess1" id="mess1" value='<bean:message key="PrintImportLevy.NoRecord"/>' />

                                        </td>
                                      </tr>

                                  </table>
                                  </td>
                                </tr>
                            </table></td>
                          </tr>
                      </table></td>
                    </tr>
                </table></td>
              </tr>

              <tr>
                <td valign="top"
                    class="padding5px">&nbsp;</td>
              </tr>
            </table>

       </html:form>
   </body>
</html>                                 
 <script type="text/javascript">    
 function clearClicked(){
  document.forms[0].elements["FDate"].value="";
  document.forms[0].elements["TDate"].value="";
  document.forms[0].action='<%=request.getContextPath()%>'+'/LevyPayersByRegionAction.do?methodToCall=clearSelectedRole';

  document.forms[0].submit();      
 }
 function getSelectFile()
 {
  document.forms[0].action='<%=request.getContextPath()%>'+'/LevyPayersByRegionAction.do?methodToCall=onUserFileSelect';
  document.forms[0].submit();
  }      


 function generateClicked()
 {
    if (validateRequired(document.forms[0])) {
       var fromdate  = document.forms[0].elements["FDate"].value;
       var todate =document.forms[0].elements["TDate"].value;
       var regionName = document.forms[0].elements["regionName"].value;        
       var sectorName=document.forms[0].elements["sectorName"].value;    

       if((comparWithSysDates(fromdate))&&(comparWithSysDates(todate))) {
         if(comparDates(fromdate,todate)) { 
            window.open("reportJSP/PrintClaimByRegion.jsp?fromdate="+fromdate+"&todate="+todate+"&regionName="+regionName+"&sectorName="+sectorName,'classPop', "location=1,status=1,scrollbars=1,width=900,height=750,left=100,top=150"); 
        }
      }

     }
  }   

</script>

I have configured it struts_config.xml

 <forward name="LevyPayersByRegion" path="/levycollection/LevyPayersByRegion.jsp"/> 

and this is the Action class method

public ActionForward LevyPayersByRegion(ActionMapping mapping, 
                                   ActionForm form, 
                                   HttpServletRequest request, 
                                   HttpServletResponse response) {


     VTFSInterface vtfsInteface = new VTFSInterface();
     ArrayList citylist = vtfsInteface.getPhysicalRegionSelect();
     request.getSession().setAttribute("citylist", citylist);
     request.setAttribute("citylist", citylist);
     ArrayList sectorlist = vtfsInteface.getSectorSelect();
     request.getSession().setAttribute("sectorlist", sectorlist);
     request.setAttribute("sectorlist", sectorlist);

     return mapping.findForward("LevyPayersByRegion");
}

but when i tried to run it i am getting this

function validateFloatRange(form)
    { var isValid = true; var focusField = null; var i = 0; var fields = new       Array(); oRange = new floatRange(); for (x in oRange) { var field = form[oRange[x][0]]; if ((field.type == 'text' || field.type == 'textarea') && (field.value.length > 0)) { var fMin = parseFloat(oRange[x][2]("min")); var fMax = parseFloat(oRange[x][2]("max")); var fValue = parseFloat(field.value); if (!(fValue >= fMin && fValue <= fMax)) { if (i == 0) { focusField = field; } fields[i++] = oRange[x][1]; isValid = false; } } } if (fields.length > 0) { focusField.focus(); alert(fields.join('\n')); } return isValid; } function validateByte(form) { var bValid = true; var focusField = null; var i = 0; var fields = new Array(); oByte = new ByteValidations(); for (x in oByte) { var field = form[oByte[x][0]]; if (field.type == 'text' || field.type == 'textarea' || field.type == 'select-one' || field.type == 'radio') { var value = ''; // get field's value if (field.type == "select-one") { var si = field.selectedIndex; if (si >= 0) { value = field.options[si].value; } } else { value = field.value; } if (value.length > 0) { if (!isAllDigits(value)) { bValid = false; if (i == 0) { focusField = field; } fields[i++] = oByte[x][1]; } else { var iValue = parseInt(value); if (isNaN(iValue) || !(iValue >= -128 && iValue <= 127)) { if (i == 0) { focusField = field; } fields[i++] = oByte[x][1]; bValid = false; } } } } } if (fields.length > 0) { focusField.focus(); alert(fields.join('\n')); } return bValid; }

along with my jsp page. i have found that these function are in validator.xml file how can i remove them or atleast make them disappear while displaying my jsp.


Solution

  • The JSP page is made for client-side validation, thus using <html:javascript> you include javascript on the page used for this type of validation. Remove this tag, or try with its attributes like dynamicJavascript or staticJavascript to set them to false. The default settings is true. These attributes are used for configuring whether or not to render the dynamic or static JavaScript.