I'm relatively new to JSPs, and I'm trying to use a FormBean within one of my files.
When I try to open the JSP page on a local Tomcat server, I get the following error:
org.apache.jasper.JasperException: /entryForm.jsp (line: 4, column: 21) equal symbol expected
The first five lines of my code are:
<!DOCTYPE html>
<%# page import = "jared.simpledatabase.* %>
<jsp:useBean id="form" class="jared.simpledatabase.FormBean" scope="session"/>
<jsp:setProperty name="form" property="*"/>
Any ideas what I'm doing wrong? Thanks!
Here's a guess - missing double quote:
<%# page import = "jared.simpledatabase.*" %>
In my case it was a missing " in the jsp:param tag e.g.
<jsp:param name="X" value="{$someValue}/>
Changing it to ... fixed the issue
<jsp:param name="X" value="{$someValue}"/>
Related
Hi I am getting an error where my s:select will work fine in the parent jsp file but when it is within another jsp file that is being called upon by the parent.jsp it doesn't seem to work anymore. I removed everything down to just these two lines and all the extra stuff around the select. Any suggestion or advice is greatly appreciated!
parent.jsp
<%# taglib uri="/struts-tags" prefix="s" %>
<s:select label="some label"
list="#{'01':'Dev','2':'Manager','03':'Customer'}"
name="test"
/>
<s:component template="child.jsp" templateDir="/pub/" theme="folder1" />
child.jsp
<%# taglib uri="/struts-tags" prefix="s" %>
<s:select label="some label"
list="#{'01':'Dev','2':'Manager','03':'Customer'}"
name="test"
/>
File structure
/pub
----/folder1
--------parent.jsp <-- dropdown displays appears
--------child.jsp <--- dropdown breaks
Error message
Struts Problem Report
Struts has detected an unhandled exception:
Messages:
Non-normalized name, starts with "/": /pub//simple/select.ftl
File:
freemarker/cache/TemplateCache.java
Line number:
914
From what I understand turns out it seems to be that you need to set the templateDir inside the child.jsp to the path to the template directory that it is within Struts 2 so it can find the code for s:select. This code managed to fix the issue:
<s:set var="templateDir" value="%{'template'}" scope="page"/>
i am learning JSTL and from tutorials point in this link
when i tried to execute that example in the page which is
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title><c:url> Tag Example</title>
</head>
<body>
TEST
</body>
</html>
i am getting following error.
but i could not understand why and what is the solution for that?
The validator is probably confused by the nested double quotes:
TEST
You can make the code cleaner by doing:
<c:url value="/jsp/index.htm" var="myUrl" />
TEST
which assigns the value of the processed URL to a var named 'myUrl' and then uses JSP Expression language to output the URL.
Change this line:
<title><c:url> Tag Example</title>
By:
<title><c:url> Tag Example</title>
Otherwise, the JSP engine will interpret this (<c:url>) as the beginning of a tag to be processed.
You need to escape your nested quotes as
TEST
Otherwise the HTML parser perceives "<c:url value=" as the href value and complains about the space in between. Alternatively, you can make use of single and double quotes as
<a href='<c:url value="/jsp/index.htm"/>'>TEST</a>
Or,
TEST
I am trying to execute the following jsp code which contains the optiontransferselect tag. However I am getting the below exception:
org.apache.jasper.JasperException: /abc.jsp(10,0) No tag "optiontransferselect label" defined in tag library imported with prefix "s"
Please find the below code i have used.
<%# page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%# taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<title>Optiontransferselect Tag Example!</title>
</head>
<body>
<s:form>
<s:optiontransferselect label="Employee Records" name="leftSideEmployeeRecords" leftTitle="RoseIndia" rightTitle="JavaJazzUp" list="{'Deepak Kumar', 'Sushil Kumar','Vinod Kumar','Deepak Monthy','Deepak Mihanti', 'Sushil Kumar', 'Ravi Kant Kumar'}" headerKey="headerKey" headerValue="--- Please Select ---" doubleName="rightSideEmployeeRecords" doubleList="{'Amar Deep Patel', 'Amit Kumar','Chandan Kumar', 'Noor Kumar','Tammana Kumari'}" doubleHeaderKey="doubleHeaderKey" doubleHeaderValue="--- Please Select ---" />
</s:form>
</body>
</html>
Please Guide.
You are using older version of struts-core-xxx.jar in your project. Are you using 2.3.16 or above?
To use optiontransferselect tag you need to use struts-core-2.3.16 or higher..
You need to include the <s:head> tag which drags in some javascript that is needed to get the <s:optiontransferselect> tag to work.
Given the following preview of my JSP file in my project :
<%# page contentType="text/html; charset=utf-8" language="java"%>
<%# page import="java.util.ArrayList"%>
<%# page import="beans.UserBean"%>
<jsp:useBean id="userBean" class="beans.UserBean" scope="session" />
<jsp:useBean id="students" type="ArrayList<beans.UserBean>" scope="session" />
<jsp:useBean id="teachers" type="ArrayList<beans.UserBean>" scope="session" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
I get the following error in Eclipse :
Undefined type: ArrayList
What's wrong with it ? even though that I'm importing the ArrayList , Eclipse doesn't recognize it and shows the above message in the following two lines :
<jsp:useBean id="students" type="ArrayList<beans.UserBean>" scope="session" />
<jsp:useBean id="teachers" type="ArrayList<beans.UserBean>" scope="session" />
Any idea where did I go wrong ? Thanks
The type attribute should represent the fully qualified name of the class, not the generic declaration or so. Even more, JSP/EL is not aware of generic types in any way.
Use java.util.ArrayList instead:
<jsp:useBean id="students" type="java.util.ArrayList" scope="session" />
<jsp:useBean id="teachers" type="java.util.ArrayList" scope="session" />
All those #page import are unnecessary. They are only used when using scriptlets (those oldschool <% %> things which has been discouraged since JSP 2.0).
By the way, if those arraylists are been prepared and put in the scope by a servlet beforehand and all you need is to just access them in EL, then you do not need those <jsp:useBean> tags at all. Using the type attribute instead of the class attribute hints less or more that you're actually using a servlet. It'll work as good without those <jsp:useBean> tags. See also our servlets wiki page.
I am trying (and learning) to build a java web framework, and in the process of developing its' code generator based on the content of the database. In the view making process, I stumble in a difficulty, which I don't know how to solve it.
Firstly, I want all the pages to be created using the following index.jsp :
<body>
<%# include file="header.jsp" %>
<hr/>
<%# include file="body.jsp" %>
<hr/>
<%# include file="footer.jsp" %>
</body>
And, in the body.jsp, I want it to be like this :
<jsp:include page="${application_modul}" %>
Where application_modul is an attribute defined in its' controller this way :
request.setAttribute("application_modul","user_account\\view_user_account.jsp");
It can find the file correctly, but the processed jsp is not what I expected. Here :
<c:forEach items="[application.models.UserAccountModel#18a49e0, application.models.UserAccountModel#1f82982]" var="item" varStatus="status" >
<tr>
....
You can see the items attribute of jstl forEach, got its variable name (toString())...
Any Idea what the problem is????
I hope I describe my problem correctly
Many thanks!
PS :
I already create a quick fix for this, but not what I want it though. In the generated view_user_account.jsp, I do it like this :
<body>
<%# include file="header.jsp" %>
<hr/>
<c:forEach items="${row}" var="item" varStatus="status" >
<tr>
....
<hr/>
<%# include file="footer.jsp" %>
</body>
You can see that I create the whole file here...
EDITED:
PS : ${row} is an ArrayList populated with data from certain table
So, to summarize your problem in a single sentence, JSTL tags are not been parsed and they end up plain in generated HTML output?
You need to declare JSTL taglib in top of the JSP page where you're using JSTL tags to get them to run. For the JSTL core taglib, that'll be
<%#taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
I am not sure but, Try this...
index.jsp
<jsp:param name="parameterName" value="{parameterValue | <%= expression %>}" />