rotovibe
asked on
Javascript not parsing correctly in JSP page
Can someone help me out with this function?
I get this error when I run it.
I'm only including the script cause that is where the error occurs, I take it out and it works fine.
org.apache.jasper.JasperEx ception: ServletException in '/WEB-INF/jsp/wf-useringro up-assign. jsp': /WEB-INF/jsp/wf-useringrou p-assign.j sp(61,28) Element type "x.length" must be followed by either attribute specifications, ">" or "/>".
org.apache.jasper.servlet. JspServlet Wrapper.ha ndleJspExc eption(Jsp ServletWra pper.java: 476)
org.apache.jasper.servlet. JspServlet Wrapper.se rvice(JspS ervletWrap per.java:3 71)
org.apache.jasper.servlet. JspServlet .serviceJs pFile(JspS ervlet.jav a:315)
org.apache.jasper.servlet. JspServlet .service(J spServlet. java:265)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 803)
org.apache.struts.action.R equestProc essor.doFo rward(Requ estProcess or.java:10 56)
org.apache.struts.tiles.Ti lesRequest Processor. doForward( TilesReque stProcesso r.java:261 )
org.apache.struts.tiles.Ti lesRequest Processor. processTil esDefiniti on(TilesRe questProce ssor.java: 237)
org.apache.struts.tiles.Ti lesRequest Processor. processFor wardConfig (TilesRequ estProcess or.java:30 0)
com.docato.composer.Docato RequestPro cessor.pro cess(Docat oRequestPr ocessor.ja va:169)
org.apache.struts.action.A ctionServl et.process (ActionSer vlet.java: 1164)
org.apache.struts.action.A ctionServl et.doGet(A ctionServl et.java:39 7)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 690)
javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 803)
com.docato.util.GZIPFilter .doFilter( GZIPFilter .java:40)
com.docato.util.TidyFilter .doFilter( TidyFilter .java:33)
com.docato.util.Schematron Filter.doF ilter(Sche matronFilt er.java:13 1)
com.docato.util.XSLTFilter .doFilter( XSLTFilter .java:199)
com.docato.util.SetCharact erEncoding Filter.doF ilter(SetC haracterEn codingFilt er.java:13 7)
I get this error when I run it.
I'm only including the script cause that is where the error occurs, I take it out and it works fine.
org.apache.jasper.JasperEx
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
org.apache.struts.action.R
org.apache.struts.tiles.Ti
org.apache.struts.tiles.Ti
org.apache.struts.tiles.Ti
com.docato.composer.Docato
org.apache.struts.action.A
org.apache.struts.action.A
javax.servlet.http.HttpSer
javax.servlet.http.HttpSer
com.docato.util.GZIPFilter
com.docato.util.TidyFilter
com.docato.util.Schematron
com.docato.util.XSLTFilter
com.docato.util.SetCharact
<script type="text/javascript">
function submitAction(action)
{
document.location.href=action;
}
function onSelectChange()
{
}
function getSelections(btn)
{
var x = document.getElementById('frmMain');
for (var i=0; i<x.length; i++)
{
if (x[i].type.match(/select/i))
{
alert(x[i].name);
}
}
}
</script>
Did you close the other tags/scriptlets correctly in the rest of your JSP?
ASKER
I believe so. I will check again.
ASKER
All of the tags are closed. I am using JSTL for some dynamic data but it all works fine when I take out the javascript.
The script and the page render fine when I remove the for statement in the script like this:
function getSelections(btn)
{
var x = document.getElementById('f rmMain');
[SNIP!!!]
}
It is complaing about the for statement. Mainly the less than sign?
The script and the page render fine when I remove the for statement in the script like this:
function getSelections(btn)
{
var x = document.getElementById('f
[SNIP!!!]
}
It is complaing about the for statement. Mainly the less than sign?
your html is not well formed. check for the tag attributes placed without any space between them.
eg: <table border="0" class="tborder"width="100% ">
Should be
<table border="0" class="tborder" width="100%">
I would say a quick way is to change ur .jsp or .html file to .xml and open in a browser to validate the well formedness of ur file.
-Murali*
eg: <table border="0" class="tborder"width="100%
Should be
<table border="0" class="tborder" width="100%">
I would say a quick way is to change ur .jsp or .html file to .xml and open in a browser to validate the well formedness of ur file.
-Murali*
sorry eg: got mixed up. Here is the correct one
eg:
</table><table border="0" class="tborder"width="100% ">
Should be
<table border="0" class="tborder" width="100%">
eg:
</table><table border="0" class="tborder"width="100%
Should be
<table border="0" class="tborder" width="100%">
ASKER
I couldn't find any well-formed type errors.
Attached is the source code. Again, it complains about the for statement in the javascript.
Thanks for the help. I'm pulling my hair out!
Attached is the source code. Again, it complains about the for statement in the javascript.
Thanks for the help. I'm pulling my hair out!
<?xml version="1.0" encoding="UTF-8"?>
<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c="/tags/c"
xmlns:logic="/tags/struts-logic"
xmlns:bean="/tags/struts-bean"
xmlns:html="/tags/struts-html"
xmlns:tagx="urn:jsptagdir:/WEB-INF/tags"
xmlns:fn="/tags/functions"
version="1.2">
<jsp:directive.page import="com.docato.repository.XMLResource"/>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
.dmcstyle {
text-align: center;
font-size: small;
}
.style1 {
margin-left: 0px;
}
.gradient {
background-color: #D9E1E8;
margin: 0px;
}
.btn
{
color:#000000;
font: bold 84% 'trebuchet ms',helvetica,sans-serif;
background-color:#96A4B4;
border: 1px solid;
border-color: #696 #363 #363 #696;
filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=0,StartColorStr='#ffffffff',EndColorStr='#96A4B4');
}
</style>
<script type="text/javascript">
function submitAction(action)
{
document.location.href=action;
}
function onSelectChange()
{
}
function getSelections(btn)
{
var x = document.getElementById('frmMain');
for (var i=0; i < x.length; i++)
{
if (x[i].type.match(/select/i))
{
alert(x[i].name);
}
}
}
</script>
</head>
<body>
<!--<tagx:insert-resource-edit-scripts/>-->
<img style="margin-bottom: -2px;" src="images/activitydetails.jpg"/>
<div class="gradient">
<form action="CreateDataModule.do" method="post" id="frmMain" name="frmMain">
<table style="width: 600px;">
<tr>
<td colspan="2">
Please choose a user to assign for each activity.
</td>
</tr>
<tr>
<td style="border-bottom: #999999 1px solid;" >
<strong>Activity</strong>
</td>
<td style="border-bottom: #999999 1px solid;" >
<strong>User</strong>
</td>
</tr>
<c:forEach items="${activities}" var="activity" >
<tr style="background-color: ${((loop.index % 2) == 0) ? 'whitesmoke' : '#eeeeee'};">
<td >
${activity.wfActivityDefinition.activityName}
</td>
<td>
<select name="${activity.wfActivityDefinition.activityName}" id="${activity.wfActivityDefinition.activityName}" onchange="onSelectChange()">
<option value="--" >--</option>
<c:forEach items="${namelist}" var="name">
<option value="${name.realName}" >
<c:out value="${name.realName}"/>
</option>
</c:forEach>
</select>
</td>
</tr>
</c:forEach>
<tr>
<td colspan="2" >
<button class="btn" onclick="getSelections(this);">
<span style="vertical-align: middle;">make assignment</span>
<img style="vertical-align: middle;" src="images/accept.png"/>
</button> 
</td>
</tr>
<!--
<tr style="border-top : 1px solid #cccccc;">
<c:forEach items="${nextTrans}" var="trans">
<td valign="left" style="border: none;"></td>
<td valign="left" style="border: none;"></td>
</c:forEach>
</tr>
-->
</table>
</form>
</div>
<br/>
<br/>
</body>
</html>
</jsp:root>
can u try to remove jsp:root tag and map all the tlds as follows, remember to remove the end jsp:root tag as well.
<%@ taglib uri="/WEB-INF/struts-bean. tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html. tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic .tld" prefix="logic" %>
-Murali*
<%@ taglib uri="/WEB-INF/struts-bean.
<%@ taglib uri="/WEB-INF/struts-html.
<%@ taglib uri="/WEB-INF/struts-logic
-Murali*
ASKER
unfortunately that is an inherited convention. I am making customizations to an existing system that uses that tag declaration format.
Works fine on the other pages. And mine does as well, except when I introduce the "<" sign in that javascript.
Works fine on the other pages. And mine does as well, except when I introduce the "<" sign in that javascript.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
THAT'S IT!!
The include works perfectly.
Much appreciated!
The include works perfectly.
Much appreciated!