jstl

Getting JSTL to run within Tomcat and Eclipse

余生长醉 提交于 2019-12-17 19:08:26
问题 I've been trying to get this to run, but I can't. I'm using Eclipse Galileo, Tomcat 5.5.23 and have several JSTLs around. My latest try was to use the GlassFish jar file "jstl-impl-1.2.jar". I placed it in Tomcat's shared lib, added it as external jar into my Eclipse project and exported it. Could anybody tell me, which jars to load in which folder and how to tell it to load in Eclipse? 回答1: It's very simple to include jstl in your projects, what I do is: Download jstl-1.2.jar (JSP 2.1

Access Session attribute on jstl

拜拜、爱过 提交于 2019-12-17 18:27:54
问题 I am trying to access a session attribute from a jsp page which is set and dispatched by a servlet, but I am getting the error message "jsp:attribute must be the subelement of a standard or custom action". What could be wrong, am I accessing it incorrectly? The following is the code snippet. Servlet: protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); session.setAttribute("Questions",

Using JSP code in JavaScript

两盒软妹~` 提交于 2019-12-17 18:24:01
问题 I want to use JSTL's fmt tag in JavaScript to localize my alert messages. My JavaScript file is a standalone file and when I include fmt tag in js, the file browser gives JavaScript errors. Is it possible to treat .js file as .jsp files using web.xml configuration? Can anyone please suggest how can I do that? 回答1: is it possible to treat .js file as .jsp file using web.xml configuration? Yes: <servlet> <servlet-name>scriptjsp</servlet-name> <jsp-file>/script.jsp</jsp-file> </servlet> <servlet

How to obtain request / session / servletcontext attribute in JSP using EL?

眉间皱痕 提交于 2019-12-17 17:58:07
问题 I know this isn't hard, but I'm not having any luck. I want to make fooList from a Servlet available in a JSP. So in the Servlet I have: request.setAttribute("list", fooList); RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/myJsp.jsp"); dispatcher.forward(request, response); Then in the JSP, I want: <c:forEach var="post" items="${SOME_EL_HERE}"> <!-- stuff --> </c:forEach> Where SOME_EL_HERE is an expression that retrieves the attribute that I have set on the request

Evaluate if list is empty JSTL

安稳与你 提交于 2019-12-17 17:25:31
问题 I've been trying to evaluate if this array list is empty or not but none of these have even compiled: <c:if test="${myObject.featuresList.size == 0 }"> <c:if test="${myObject.featuresList.length == 0 }"> <c:if test="${myObject.featuresList.size() == 0 }"> <c:if test="${myObject.featuresList.length() == 0 }"> <c:if test="${myObject.featuresList.empty}"> <c:if test="${myObject.featuresList.empty()}"> <c:if test="${myObject.featuresList.isEmpty}"> How can I evaluate if an ArrayList is empty? 回答1

EL any function to get absolute value of a number?

旧城冷巷雨未停 提交于 2019-12-17 17:05:10
问题 I know the ugly way a>0 ? a : -a but this is very annoyng when a is a relatively long expression. OBJ1["x"]-someVar>0 ? OBJ1["x"]-someVar : -(OBJ1["x"]-someVar) Is there any nicer way of doing it? 回答1: For plain jsp, you can create a custom EL function which delegates to Math#abs(int). If you first just create a /WEB-INF/functions.tld file which look like follows: <?xml version="1.0" encoding="UTF-8" ?> <taglib xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001

How to save many objects in a spring <form:form>

我的梦境 提交于 2019-12-17 16:39:14
问题 @Component @Entity @Table(name="menu") @Configurable public class Menu implements Serializable{ .... @OneToMany(mappedBy="menu", fetch=FetchType.EAGER) private Set<VoceMenu> voceMenuList; public Set<VoceMenu> getVoceMenuList() { return voceMenuList; } public void setVoceMenuList(Set<VoceMenu> voceMenuList) { this.voceMenuList = voceMenuList; } ..... } I print a form to edit the menu, and its relative VoceMenu objects, this way: <form:form action="editMenu" method="post" commandName="menu">

Using JSTL causes deferredExpression error on change

帅比萌擦擦* 提交于 2019-12-17 16:28:21
问题 I recently removed all scriptlets on my project as advised by this post. But now, if I try and make a change to one of my views, I get a deferredExpression error. To get rid of the error, I simply have to terminate, then restart the project. What is going on here? Is eclipse not able to compile jstl on the fly? Is there something I can change so I don't have to redeploy every time I make a change? Stack Trace java.lang.NoSuchFieldError: deferredExpression at org.apache.taglibs.standard.tag

Unicode characters in servlet application are shown as question marks

喜你入骨 提交于 2019-12-17 10:03:47
问题 Recently I have implemented internationalization based on How to internationalize a Java web application?. But now I am facing a problem in some of the pages. If it is English language, it is showing well, but if we choose any other language then all the values in that page are showing as ????????? . I have checked for exceptions in server logs, but I couldn't find anyone. How is this caused and how can I solve it? 回答1: Seeing ?????? instead of intelligible characters (and even instead of

How to set the JSTL variable value in javascript?

六月ゝ 毕业季﹏ 提交于 2019-12-17 05:01:27
问题 How to set the JSTL variable value in java script? <script> function function1() { var val1 = document.getElementById('userName').value; <c:set var="user" value=""/> // how do i set val1 here? } </script> How do I set the ' user ' variable ( JSTL ) value from ' val1 ' ( Java script )? 回答1: It is not possible because they are executed in different environments (JSP at server side, JavaScript at client side). So they are not executed in the sequence you see in your code. var val1 = document