jstl

multiple radio button selection

被刻印的时光 ゝ 提交于 2019-12-24 09:31:10
问题 I've to display many groups and many products under each group. For displying them I'm using JSTL to iterate the list of products from the list of groups. User can select one product from each group by clicking on the radio. To enable this i've added the id of the group with the radio name, so that user can select multiple radios. How can get the selected radios from the servlet? Because the name is created dynamically. <c:forEach items="${pgb.tableValues}" var="tv"> <tr> <c:forEach items="$

How to add 30 days in a timestamp in jstl

时间秒杀一切 提交于 2019-12-24 08:58:33
问题 I need to add 30 days to the current system date in timestamp. How can I acheive that? I am having below code: <% Date date= new Date(); long time = date.getTime(); Timestamp ts = new Timestamp(time); %> <c:set var="currentDate"><%=ts%></c:set> <c:if test="${startDate lt currentDate}"> <c:if test="${endDate gt currentDate}"> How can I make ts+ 30? Thanks in advance. 回答1: Use calendar: Calendar cal=new GregorianCalendar(); cal.add(Calendar.DATE, 30); Date d=cal.getTime(); 回答2: <%@taglib uri=

The method getPart(String) is undefined for the type HttpServletRequest

倖福魔咒の 提交于 2019-12-24 07:45:26
问题 I have been working on Java web project in which i need to upload an image through the JSP page and store it into a MySQL database. I'm entering the image in multiparts which is available for Servlet 3.0 or above. I've been using the getPart("image") to get the image part by part but it's showing me the following error: "The method getPart(String) is undefined for the type HttpServletRequest" The server i'm using: Tomcat 7 The IDE i'm using: Eclipse Luna Here are the code snippets:

How to iterate an object over a list of objects in JSTL?

南楼画角 提交于 2019-12-24 06:47:17
问题 I have a class named Language with 1 field named name . I have another class named Speech which has a language member. I need to iterate over a list of Speech objects. In JSTL: <c:forEach items="${requestScope.Speech}" var="speech"> <tr> <td> ${speech.id}</td> <td> ${speech.language.name}</td> </tr> </c:forEach> My second statement ${speech.language.name} doesn't work. How can I make it work? Speech and Language classes: public class Speech { private int id; private Language language=null;

Installing JSTL results in org.xml.sax.SAXParseException: Content is not allowed in prolog

浪尽此生 提交于 2019-12-24 02:39:13
问题 In my application I am using JSTL. But when I am deploying my application in Tomcat I am getting below error. SEVERE: Parse Fatal Error at line 1 column 1: Content is not allowed in prolog. org.xml.sax.SAXParseException: Content is not allowed in prolog. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174) at com.sun.org.apache

jsp how to get base url cleanly without javascript

╄→гoц情女王★ 提交于 2019-12-24 02:19:11
问题 I'm trying to get the base url (for example: https://stackoverflow.com/) without using javascript. But there seem to be a lot of ways to split it off from https://stackoverflow.com/questions/ask so I was wondering what the cleanest way was (or if there's a preferred method). jstl functions would probably do the trick, but I'd like it to be as dynamically as possible, so I wouldn't have to change it if the /questions/ part was to change to let's say /question/. ${pageContext.request.scheme}://

Embedded Jetty fails to load JSP taglibs when classpath specified in jar

Deadly 提交于 2019-12-24 02:18:16
问题 I'm running into a problem that doesn't seem to be addressed by the similar questions. I have an app that embeds Jetty, using SpringMVC, JSPs and taglibs. I use a maven plugin to generate a jar, bundle all the dependent jars into a directory and create a manifest. When I run the app using the jar (eg. java -jar app.jar) everything works fine until I try to load a JSP that specifies <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> or any other taglib for that matter. If I run

Pass XML document via attribute or body to JSP custom tag

房东的猫 提交于 2019-12-24 02:09:33
问题 I wonder if it's possible to pass an xml document to a pure jstl-defined JSP custom tag either as: the body of the custom tag, such as: <mt:mytag> <people> <person name="bob" age="23" /> <person name="sue" age="45" /> <person name="moe" age="35" /> </people> <mt:mytag> or as an attribute of the tag like this: <mt:mytag message="http://link.to.document.xml" /> This is the tag itself <%@tag description="xml parser" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix

How to find length of an integer in JSP?

半世苍凉 提交于 2019-12-24 00:58:34
问题 I can use fn:length(mystring) to find the length/number of character of a string. How can I find the length/number of digits in an integer? e.g. if my int is 3000, I want to return 4. 回答1: Convert it to String first by evaluating it as body of <c:set>: <c:set var="intAsString">${someInt}</c:set> Then you can get its length the usual way: ${fn:length(intAsString)} 来源: https://stackoverflow.com/questions/10343203/how-to-find-length-of-an-integer-in-jsp

Using a4j:repeat or ui:repeat inside rich:dataTable doesn't render radio buttons properly

与世无争的帅哥 提交于 2019-12-24 00:30:06
问题 While using <c:forEach> the items values is not substituted properly. If i use <a4j:repeat> or <ui:repeat> instead of <c:forEach> inside a <rich:dataTable >, radio button is not rendering properly. I also found reason for this in http://community.jboss.org/wiki/Cantusea4jrepeattoiteratethemenuItemstabsetc How do I resolve this issue? <f:selectItems> is working inside but i want to send a choice type to server <rich:dataTable var="answer" value="#{answers}"> <rich:column> <f:selectOneRadio