jsp-tags

How could I get a parameter in JSP?

隐身守侯 提交于 2019-12-02 10:59:53
Here is my action execute() method, @Override public String execute() throws Exception { ActionContext aContext = ActionContext.getContext(); aContext.getParameters().put("reqVar1", "reqVar1-Value"); return SUCCESS; } I want to get the parameter value in JSP like below code, <s:property value="#parameters.reqVar1" /> but it doesn't work. I see the parameter is in stack context: How could I get the parameter value in JSP? Parameters are always use a type Map<String, String[]> . And you need to put parameter correctly, i.e. aContext.getParameters().put("reqVar1", new String[] {"reqVar1-Value"});

Making scriptlets invalid in JSPs

孤街醉人 提交于 2019-12-02 05:01:50
问题 I am trying to make scriptlets invalid by writing the below code in my Deployment descriptor but still the scriptlets are getting executed. <jsp-config> <jsp-property-group> <url-pattern>*.jsp</url-pattern> <scripting-invalid>false</scripting-invalid> <el-ignored>true</el-ignored> </jsp-property-group> </jsp-config> 回答1: You need to configure it the other way round. <scripting-invalid>true</scripting-invalid> <el-ignored>false</el-ignored> When the <scripting-invalid> is set to true , then

How to perform pagination in jsp

瘦欲@ 提交于 2019-12-02 03:54:35
问题 i need pagination concept to display 15 records. this is my jsp file. <% ArrayList<String> al = new ArrayList(); %> <%!String s; int i;%> <% al = op.getCountry(); %> <jsp:scriptlet> session.setAttribute( "EmpList", al); </jsp:scriptlet> <display:table id="domList" pagesize="10" name="sessionScope.EmpList"> <table width="100%" border="0" cellpadding="0" cellspacing="0" id="dataTable"> <tr bgcolor="#57e3ff"> <td><strong>Country</strong></td> <td colspan="2" align="center"><strong>Action</strong

Making scriptlets invalid in JSPs

[亡魂溺海] 提交于 2019-12-02 02:38:58
I am trying to make scriptlets invalid by writing the below code in my Deployment descriptor but still the scriptlets are getting executed. <jsp-config> <jsp-property-group> <url-pattern>*.jsp</url-pattern> <scripting-invalid>false</scripting-invalid> <el-ignored>true</el-ignored> </jsp-property-group> </jsp-config> You need to configure it the other way round. <scripting-invalid>true</scripting-invalid> <el-ignored>false</el-ignored> When the <scripting-invalid> is set to true , then the container will throw an exception when scriptlets (those <% %> , <%= %> and <%! %> things) are still used.

How to perform pagination in jsp

两盒软妹~` 提交于 2019-12-02 02:26:06
i need pagination concept to display 15 records. this is my jsp file. <% ArrayList<String> al = new ArrayList(); %> <%!String s; int i;%> <% al = op.getCountry(); %> <jsp:scriptlet> session.setAttribute( "EmpList", al); </jsp:scriptlet> <display:table id="domList" pagesize="10" name="sessionScope.EmpList"> <table width="100%" border="0" cellpadding="0" cellspacing="0" id="dataTable"> <tr bgcolor="#57e3ff"> <td><strong>Country</strong></td> <td colspan="2" align="center"><strong>Action</strong></td> </tr> <% int a = 0, i = 0; while (i < al.size()) { if ((i + 1) % 2 == 0) { s = "#f3f4f4"; } else

JSP custom tag library (Passing Attributes)

被刻印的时光 ゝ 提交于 2019-12-02 02:04:15
问题 I'm trying to use multiple attributes in my custom tag, e.g.: <mytaglib:mytag firstname="Thadeus" lastname="Jones" /> How can I access the attributes in the TagHandler code? 回答1: Not really the answer to what you asked, but I hate (ie have never written) TagHandler's but I love tag files. Lets you write custom tags using jsp files. You probably know about them and are not available/applicable - but thought I'd mention them just in case. 回答2: In order to access the parameters your TagHandler

JSP custom tag library (Passing Attributes)

妖精的绣舞 提交于 2019-12-01 23:51:20
I'm trying to use multiple attributes in my custom tag, e.g.: <mytaglib:mytag firstname="Thadeus" lastname="Jones" /> How can I access the attributes in the TagHandler code? Not really the answer to what you asked, but I hate (ie have never written) TagHandler's but I love tag files . Lets you write custom tags using jsp files. You probably know about them and are not available/applicable - but thought I'd mention them just in case. In order to access the parameters your TagHandler class should define the private members and provide accessor methods. public class TagHandler extends TagSupport

Change Struts 2, i18n classes behavior when key is not found

女生的网名这么多〃 提交于 2019-12-01 21:19:55
We used getText in actions, setMessageKey in validators and <s:text> in jsp files for an i18n application. When Struts 2 could not find a key in resource bundles it returns the key itself. For example form.transfer.confirm . How can we change this behavior in the way that instead of the key itself Struts2 returns empty string. You need to create custom implementation of TextProvider and override getText methods in it. 1) Create class (e.g. EmptyDefaultTextProvider ) extending one of TextProvider existing implementations (e.g. TextProviderSupport ). 2) Override all getText methods like that:

Spring-Boot with JSP Tag Libs in embedded Tomcat

天涯浪子 提交于 2019-12-01 19:22:52
问题 I am currently migrating a Spring MVC Webapp (xml-config to java-config, tomcat to embedded tomcat via spring-boot). The webapp uses freemarker as templating engine and JSP Taglibs. Now when I call a freemarker page I get the following error: freemarker.ext.jsp.TaglibFactory$TaglibGettingException: No TLD was found for the "http://www.springframework.org/tags/form" JSP taglib URI. (TLD-s are searched according the JSP 2.2 specification. In development- and embedded-servlet-container setups

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

倖福魔咒の 提交于 2019-12-01 08:05:12
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 accept any expressions How should I write for that, pls give me some suggestions. Don't use scriptlets