jsp-tags

Recommended JSP table taglib?

女生的网名这么多〃 提交于 2019-12-12 23:22:52
问题 Can you recommend a declarative table-generation taglib for JSP (with EL) that is still being maintained? I found a few, such as the Jakarata taglib and Display tag but nothing seems to have been updated in the past year or so. Any recommendations would be appreciated. 回答1: It's true that Displaytag development seems to be moribund, but I'm using it in an application and other than a couple of minor issues we haven't had problems. The source is pretty clean and easy to customize/fix if you're

what is the difference between uri and tagdir in JSP taglib

你离开我真会死。 提交于 2019-12-12 18:36:10
问题 I am cofused between tagdir and uri used in taglib directive. What is the real difference between using tagdir and uri ? Examples : <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="notMyTags" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="otherTags" %> <%@ taglib tagdir="/WEB-INF/tags" prefix="myTags" %> to the best of my understanding: 1) I can access non-custom tags from the uri referencing them by the provided prefix (e.g.: if the uri defines the tag hello , in the page

Custom JSP tag - detect existence of other instances

随声附和 提交于 2019-12-12 15:52:03
问题 Is it possible for a custom JSP tag to detect if there are other instances of itself within a page? If so, what's the preferred way to do this? My tag's output needs to be conditional dependent upon whether it's the only instance or not. Note that my page has three occurences of my tag, two of which have a different set of attributes from the third, so I know that there are two separate instances of the tag allocated from the resource pool. 回答1: You could make use of the PageContext

Custom JSP tag - How do I get the body of the tag?

徘徊边缘 提交于 2019-12-12 07:50:01
问题 I have a custom jsp tag like this: <a:customtag> The body of the custom tag... More lines of the body... </a:customtag> In the custom tag, how can I get the text of what the body is? 回答1: It's complicated because there are two mechanisms. If you're extending SimpleTagSupport, you get getJspBody() method. It returns a JspFragment that you can invoke(Writer writer) to have the body content written to the writer. You should use SimpleTagSupport unless you have a specific reason to use

How does JSP process concurrent requests?

南笙酒味 提交于 2019-12-12 01:53:40
问题 I guess my question is, a JSP is compiled into a single servlet instance that serve multiple requests. How do I make it threadsafe? 回答1: Servlets are meant to be immutable. Either no state exists outside of method calls (the servlet is stateless), or any such state will never change (so the state that each thread sees is always the same). It's extremely simple to write a threadsafe servlet: never use instance variables. Use method-local variables. 回答2: Just don't assign request/session

Define a jsp tag which can accept some extra attributes which are not declared in the tld file

三世轮回 提交于 2019-12-11 18:23:53
问题 I want to define a jsp tag, which can accept some extra attributes which are not declared in the .tld file. Is it possible? I want this because I want to define a <cms:img> tag, which will generate a html img tag. User can pass some attributes to it, but I don't want to limit user, I hope they can use it just as a normal html img tag. For example, user can use this tag and pass some required information: <cms:img id="111" /> Which will generate a html img tag as: <img src="/show_images?id=111

Display tag Issues with pagination and sorting

北战南征 提交于 2019-12-11 12:45:29
问题 I am using display tag to render tables in my application. When I click either pagination or sorting, it's querying the database again and then sorting/paging. In my opinion, when we are only sorting/paging, we need not query database. I see following options to tackle this: I can keep the list (queried from the db) in the session and check it this request is for sorting or pagination then return the list from the session Or I can maintain a server side cache which will work the same as above

How to make colspan with display:column

巧了我就是萌 提交于 2019-12-11 11:45:25
问题 I want to make a colspan in a display:column so I tried to do it as follows: <display:column style="width=50% colspan=2 " title="${textResources['Exam.endDate']}"> but it doesn't work it seems that this property is not allowed in a display:column so how to do that? 回答1: To add a colspan to the display column you have to create a Table Decorator extends the TableDecorator class, override the method init, in this method you need to get the header for your cell and add the colspan attribute.

jsp:param no longer sets parameters when original request is wrapped with a HttpServletRequestWrapper

不打扰是莪最后的温柔 提交于 2019-12-11 10:38:13
问题 I have a filter that takes an incoming request, and then wraps it with an HttpServletRequestWrapper, which in turn has a setParameter() method on it. However, this will no longer work now in any filtered servlets: <jsp:include page="testing-include.jsp"> <jsp:param name="testing" value="testing" /> </jsp:include> The include page will not take the request parameter. If I remove the filter, and the original unmodified request is sent (unwrapped) to the servlet, then it works again. Here is my

Set id of select options to jstl variable

放肆的年华 提交于 2019-12-11 09:52:58
问题 I've a JSP page that load some info from a DAO to a select element. Something like this: <select id="dropdown" onchange="changeKa()"> <c:forEach var="ka" items="${KaList}"> <option value="<c:out value='${ka.area}' />" <c:if test="${param.selectValue == ka.area})"> selected </c:if> > <c:out value="${ka.area}" /> </option> </c:forEach> </select> Where I have <option value="<c:out value='${ka.area}' />" ... I want to set an id like this: <option value="<c:out value='${ka.area}' />" id="<c:out