jsp-tags

i18n translation in JSP custom tag

旧街凉风 提交于 2020-01-02 06:57:09
问题 Is it possible to write a custom JSP tag to take an i18n message key and output the translation phrase for the given request? Normally in JSP/JSTL, I do: <fmt:message key="${messageKey}"><fmt:param>arg1</fmt:param></fmt:message> And I get the translation phrase. Now I need to do the following (there's a good reason for this): <custom:translate key="${messageKey}" arg="arg1"/> But I don't know how to look up the translation in the custom tag code. The TagSupport base class provides a

Where do I put the .tld file so that the resulting JAR file built with maven2 is properly packaged?

匆匆过客 提交于 2020-01-01 09:26:26
问题 I currently have the following directory structure for my code: src |-- main | `-- java | `-- com | `-- upthescala | `-- tags | `-- ViewProtectTag.java |-- test |-- pom.xml |-- .project |-- .classpath `-- .hgignore I want to include a tld file for my JSP tag, and I'm not sure where to package it. My initial thought is to add a src/main/resources directory and put META-INF/viewprotect.tld in there. 回答1: My initial thought is to add a src/main/resources directory and put META-INF/viewprotect

How can I pass an object to a JSP tag?

僤鯓⒐⒋嵵緔 提交于 2020-01-01 03:53:26
问题 I have a JSP page that contains a scriplet where I instantiate an object. I would like to pass that object to the JSP tag without using any cache. For example I would like to accomplish this: <%@ taglib prefix="wf" uri="JspCustomTag" %> <% Object myObject = new Object(); %> <wf:my-tag obj=myObject /> I'm trying to avoid directly interacting with any of the caches (page, session, servletcontext), I would rather have my tag handle that. 回答1: A slightly different question that I looked for here:

java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext;

匆匆过客 提交于 2019-12-31 04:22:57
问题 I am trying to set a variable that I will refer to in a custom JSP tag, so I have something like this in my JSP: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <c:set var="path" value="test"/> However, I am getting this error when The JSP runs: java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext; at org.apache.taglibs.standard.tag.common.core.SetSupport.doEndTag(SetSupport.java:140) I am running Tomcat 5.5, and Java 1.5, with JSTL 1

How do I make JSP tag files NOT ignore all whitespace?

感情迁移 提交于 2019-12-30 08:22:31
问题 I'm really stumped on this one. I want to output a list and have the tag file take care of commas, singular versus plural, etc. but when I display the list it completely ignores whitespace so everythingrunstogetherlikethis. I tried using the HTML entities "thinsp", "ensp" and "emsp" (I can't use "nbsp", these have to be breaking), but they're all hideously wide on IE except thinsp which is way too skinny on everything else. Edit: won't work. The output from the tag has no spaces at all.

IlleagalStateException when wrapping spring mvc select tag with custom tag

北战南征 提交于 2019-12-25 07:48:01
问题 Basic problem I've come across a bit of a problem while writing my own custom JSP tags to "wrap" the spring MVC form tags. I've wrapped other tags successfully but come unstuck with the select and options tags, this throws an IlleagalStateException. I've debugged the spring code and found that the options tag looks for an ancestor select tag. I'm doing this with tag files so the spring select tag is actually in a different tag file. I guess that's why it doesn't find it. So the questions is

Concatenate of a string within a loop in JSP

守給你的承諾、 提交于 2019-12-25 06:59:33
问题 ${x}="mit" ${Place['name_mit']} will give result as US. But if I try ${Place['name_'+x]} I get error. How to resolve this ? 回答1: Yes, it fails to compile as + operator is not used for string concatination (before EL 3.0, Java EE 7). Just use concat ${Place['name_'.concat(x)]} From Expression Language 3.0, It is valid to use + operator for concatenation of two strings. ${Place['name_'+x]} //valid as of EL 3.0 From EL 3.0 Specs String Concatenation Operator To evaluate A += B Coerce A and B to

Assign java object from response to a custom JSP tag communicated using AJAX

让人想犯罪 __ 提交于 2019-12-25 02:17:27
问题 I have a button in JSP, when clicked, goes to a servlet stores a java object using request.setAttribute("attr", object) and forwards to another page. In that page, I am using a custom JSP tag which gets this attribute and displays some values. Now I want this all to happen using AJAX. I want to have only one page which submits a form and receives an object to be used by custom JSP tag in the same page. How do I do this ? Is there a reliable library for that ? From what I see, in ajax I can

Using angular js form validations in <form:input> tag

人走茶凉 提交于 2019-12-24 16:48:02
问题 I have created a jsp page having a spring form. I want to validate the form using angular js. When I try to add required and ng-model attributes inside <form:input> tag, I'm getting exception Jasper exception equal symbol expected and Attribute ng-model invalid for tag input according to TLD in the line where i added these attributes. What is the procedure to make my logic work? 回答1: There are 4 things you can try: First one: Probably the neatest, and I think this should work: <form:input

Adding data attribute in form:options, i.e., in options.tag

人走茶凉 提交于 2019-12-24 13:59:00
问题 I have a list of objects in the pageContext and I want some of it's attribute in the data attribute of the option tag of select. Below is the jsp code : <form:select class="required chzn_a" disabled="${view}" path="one.id" id="one"> <form:option value="">Select</form:option> <form:options items="${objectList}" itemValue="id" itemLabel="name"/> </form:select> I want something like below : However, below is what I am getting : 回答1: As far as I know the form:options tag does not support