jsp-tags

Charset of JSP tags

╄→гoц情女王★ 提交于 2019-12-05 01:28:56
问题 Simple question about charset of JSP tags. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib tagdir="/WEB-INF/tags" prefix="custom" %> <custom:mytag> </custom:mytag> mytag is simple . tag file located in WEB-INF/tags . Charset of this file in eclipse is UTF-8. For some reason UTF-8 symbols do not display properly. This affect only including tags, another jsp-s that was included display fine 回答1: <%@tag pageEncoding="UTF-8"%> placed in your tag

Passing a Java object value in Custom JSP tag

廉价感情. 提交于 2019-12-05 01:28:22
I'm trying to pass a java variable from a custom jsp tag(Im using struts2 here to get the variable from the java class). Here is the error I'm getting. javax.servlet.ServletException: /pages/editBidForm.jsp(51,8) According to TLD or attribute directive in tag file, attribute parentId does not accept any expressions org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515) org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419) .... Here is my jsp page(part) <%@ taglib prefix="s" uri="/struts-tags" %> <%@ taglib uri="/WEB-INF/taglib.tld" prefix=

Mapping an exception to 404 page while using Spring Security taglibs

和自甴很熟 提交于 2019-12-04 19:18:23
问题 When mapping an Exception to 404 page, the Spring Security tags can't find the authentication information from the security context. With a "real" 404 the authentication is found. My web.xml: <error-page> <exception-type>com.example.NotFoundException</exception-type> <location>/app/404</location> </error-page> <error-page> <error-code>404</error-code> <location>/app/404</location> </error-page> On the JSP I have: <sec:authorize access="hasRole('ROLE_USER')"> <%-- Show navigation links --%> <

How to get full URL in JSP

喜夏-厌秋 提交于 2019-12-04 12:51:48
How would I get the full URL of a JSP page. For example the URL might be http://www.example.com/news.do/?language=nl&country=NL If I do things like the following I always get news.jsp and not .do out.print(request.getServletPath()); out.print(request.getRequestURI()); out.print(request.getRequest()); out.print(request.getContextPath()); Given URL = http:/localhost:8080/sample/url.jsp?id1=something&id2=something&id3=something request.getQueryString(); it returns id1=something&id2=something&id3=something See This You need to call request.getRequestURL() : Reconstructs the URL the client used to

javax.el.PropertyNotFoundException: The class 'java.lang.String' does not have the property

只谈情不闲聊 提交于 2019-12-04 12:13:45
I am creating Sample Spring MVC application. In my Controller class I have define like this: Map<String, Object> myModel = new HashMap<String, Object>(); myModel.put("now", now); myModel.put("products", this.productManager.getProducts()); return new ModelAndView("hello", "model", myModel); When I put following part in my JSP file i got javax.el.PropertyNotFoundException exception <c:forEach items="${model.products}" var="prod"> <c:out value="${prod.description}"/> <i>$<c:out value="${prod.price}"/></i><br><br> </c:forEach> Here is my full exception : javax.el.PropertyNotFoundException: The

How to pass Object using jsp:include param tag into another jsp

这一生的挚爱 提交于 2019-12-04 10:04:28
问题 I am trying to send DTO Object from one jsp to another jsp using jsp:include tag. But it is always treating it as String. I can't able to use DTO in my included jsp file. Here is a code .. <c:forEach items="${attributeDTOList}" var="attribute" varStatus="status"> <jsp:include page="attributeSubFeatureRemove.jsp" > <jsp:param name="attribute" value="${attribute}" /> </jsp:include> </c:forEach> attributeSubFeatureRemove.jsp file .. <c:set value="${param.attribute}" var="attribute" /> <c:forEach

Scope of jsp:useBean

你离开我真会死。 提交于 2019-12-04 09:50:04
问题 home.jsp <jsp:useBean id="username" class="java.lang.String" scope="application"/> <% username="Jitendra"; %> <jsp:include page="include.jsp"/> include.jsp <%=username%> This gives an error saying “username” is undefined in include.jsp, even though the scope of Bean is application… 回答1: As to your problem, anything which you declare locally using the old fashioned scriptlets is not linked with a jsp:useBean . Also, declaring a local scriptlet variable is not visible in the included pages, you

How can I make a custom JSP tag that uses other JSP tags?

戏子无情 提交于 2019-12-04 09:19:54
问题 I would like to write a custom JSP tag whose output includes other JSP tags which should themselves also be dynamically evaluated. But apparently everything that my TagSupport subclass writes to pageContext.getOut() just goes straight to the client without any further evaluation. I have a feeling this should be very simple, since it seems like one of the very first things one would want to use custom tags for: encapsulating and reusing other custom tags, avoiding code duplication. How do I

Using java.time.LocalDate with JSTL <fmt:formatDate> action

和自甴很熟 提交于 2019-12-04 06:50:34
I haven't been able to figure out how to display a java.time.LocalDate value in a JSP. In my JSP, I have this: <fmt:formatDate value="${std.datum}" type="date" pattern="dd.MM.yyyy" var="stdDatum" /> The std.datum is of type java.time.LocalDate . When rendering the JSP I get this exception: javax.el.ELException: Cannot convert 2015-02-14 of type class java.time.LocalDate to class java.util.Date I'm assuming it's the conversion? So is it possible to format an instance of LocalDate class with <fmr:formatDate> action? user3138997 I'm assuming it's the conversion? Yes, it's a conversion related

Spring MVC <form:errors/> tag doesn't find error messages

可紊 提交于 2019-12-04 05:41:39
I work with a front-end developer who writes JSP files. We have a form that is working correctly, except validation/binding/processing errors can't seem to be displayed with Spring's <form:errors/> tag. I've confirmed that the error is being set, and what is apparently the correct path for the errors. Supposedly <form:errors path="*" /> should render them all, regardless of path, but it shows nothing. Do I need to get into the tag library source to deduce what's going wrong? 2 things I discovered. 1) make sure you specify the name of the form-bean / command object in the form tag <form:form