jsp-tags

According to TLD or attribute directive in tag file, attribute name does not accept any expressions

[亡魂溺海] 提交于 2019-12-01 07:03:26
问题 I write the following code in JSP. <% String p_loginPassword = OpeCommon.LOGIN_PASSWORD; String p_encryptCode = OpeCommon.encriptPassword(OpeCommon.KEY_USER_ID, OpeCommon.KEY_USER_PASSCODE); %> <s:url id="printURL" action="actMod" method="printout"> <s:param name="<%=OpeCommon.LOGIN_PASSWORD %>"><%=OpeCommon.encriptPassword(OpeCommon.KEY_USER_ID, OpeCommon.KEY_USER_PASSCODE)%></s:param> </s:url> It displays error : According to TLD or attribute directive in tag file, attribute name does not

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

 ̄綄美尐妖づ 提交于 2019-12-01 03:56:37
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. Although any content in the JSP has normal spacing. Obviously I could just put everything in the JSP but

JSP tag lifecycle

╄→гoц情女王★ 提交于 2019-12-01 03:09:47
I just introduced a bug into my code because I seem to have misunderstood the jsp tag lifecycle. The tag worked like this before the bug: I pass the tag some collection as an attribute, and it displays it as a table. The collection was passed into the JSP from the controller. After the bug: I removed the attribute which set the collection. Instead, in the tag I check if the collection is null, and then grab it by name from the request (using a naming convention). The thing that I didn't expect: after the collection was initially set in the tag, it would never become null on subsequent

Using JavaScript within a JSP tag

旧街凉风 提交于 2019-11-30 20:12:53
I've seen this question regading the importing of js-files related to the tag content itself. I have a similar problem, here I have a jsp tag that generates some HTML and has a generic js-implementation that handles the behavior of this HTML. Furthermore I need to write some initialization statements, so I can use it afterwards through JavaScript. To be possible to use this "handler" within my JavaScript, it should be somehow accessible. The question is... Is it Ok to write inline <script> tags along with my HTML for instantiation and initialization purposes (personally I don't think its very

Calling a custom JSP tag from JSTL tag

☆樱花仙子☆ 提交于 2019-11-30 16:12:41
问题 I'm trying to call my custom tag from the JSTL tag <c:url> . Because of the quotes, the custom tag is shown as a string instead of a tag. Can I use an escape character here? <img align="left" src="<c:url value='/getFile/getfile?<myTag:getValue type="web" name="person" />'/>" alt="person" title="person" width="55" height="70"/> 回答1: You'll have to assign the output of your custom tag to a temp variable first and then use it <c:set var="urlquerystring"><myTag:getValue type="web" name="person" /

How to clear the httpsession, if the user close the browser in java

◇◆丶佛笑我妖孽 提交于 2019-11-30 15:57:30
I am trying to clear the HttpSession if the consumer close the browser window. I dont know how to do it, Please help me anyone Thanks & Regards Chakri Stephen C If you could get the browser to (reliably) notify the server that the user had closed the window, then the server could call session.invalidate() as per the original Answer provided by ejay_francisco. The difficulty is getting the notification to happen reliably. There are various ways to detect the window close; e.g. as covered by these Questions (and similar): Trying to detect browser close event javascript to check when the browser

JSTL - Using forEach to iterate over a user-defined class [duplicate]

不问归期 提交于 2019-11-30 15:13:58
问题 This question already has answers here : javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied “items” in <forEach> (3 answers) Closed last year . What methods do I need to add to a custom Java class so that I can iterate over the items in one of its members? I couldn't find any specifications about how the JSTL forEach tag actually works so I'm not sure how to implement this. For example, if I made a generic "ProjectSet" class and I woud

JSTL - Using forEach to iterate over a user-defined class [duplicate]

守給你的承諾、 提交于 2019-11-30 13:57:01
This question already has an answer here: javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied “items” in <forEach> 3 answers What methods do I need to add to a custom Java class so that I can iterate over the items in one of its members? I couldn't find any specifications about how the JSTL forEach tag actually works so I'm not sure how to implement this. For example, if I made a generic "ProjectSet" class and I woud like to use the following markup in the JSP view: <c:forEach items="${projectset}" var="project"> ... </c:forEach> Basic

JSTL if tag for equal strings

荒凉一梦 提交于 2019-11-30 12:55:21
问题 I've got a variable from an object on my JSP page: <%= ansokanInfo.getPSystem() %> The value of the variable is NAT which is correct and I want to apply certain page elements for this value. How do I use a tag to know the case? I tried something like <c:if test = "${ansokanInfo.getPSystem() == 'NAT'}"> process </c:if> But the above doesn't display anything. How should I do it? Or can I just as well use scriptlets i.e. <% if (ansokanInfo.getPSystem().equals("NAT"){ %> process <% } %> Thanks

JSP/servlet read parameters from properties file?

戏子无情 提交于 2019-11-30 09:27:33
My JSP pages need to display different information depending on which environment they're in (dev, production, sandbox, etc). I want to have a properties file for each of these environments that contain all the parameters they might need. How can I reference the properties from this file in a JSP page? My thoughts are: Have a servlet feed the properties in the form of a model object to all JSP pages so I can reference them like ${properties.propertyName} Somehow reference this property file in the web.xml, then maybe I call something like ${context.properties.propertyName}? Instead of a