jsp-tags

Custom JSP tag - detect existence of other instances

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 fr...

news posts: put them in a .tag file or database

I'm thinking about making a simple web application to practice custom tags, EL, ... Now I'm thinking about how to make a simple front page. I want to have a front page where I'll show a short description of a post and then the user can click it to see the full article. Further down the line I'd like to attach a poster to it, and even fu...

Scope of jsp:useBean

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… ...

How to disable single radio button on JSFX page?

I have a customer who created an Oracle ADF/JSF 1.1 application. On one of the pages they have a table with first column as an enabled mutually exclusive radio buttons. I had to enhance the page and add the total line with disabled radio button. How can I disable it in Bean class or on the page without using JavaScript? I've tried to ...

jsp:text losing whitespace inside tagx

Trying to use JSPX and running into a strange problem. Text inside jsp:text is supposed to not be subject to whitespace removal, according to the JSP documentation, but when I have a jsp:text element with leading whitespace in the beginning of a tagx file, when used in the jspx views, the leading whitespace disappears. I've done quite ...

Design question - servlets, jsps, custom tags, html

Hi, I am new to servlets and jsps. I wanted to know what the best design would be for a sample problem I am trying to write code for. Here goes - I want to create a web site (www.example.com) that just lists the login history of every user (not any functionility any one wants but just an example for the sake of one). So there are two...

keeping track of multiple related input boxes using spring mvc

we have a list of domain objects needing to be edited on an html page. For example, the command & domain objects: class MyCommand { List<Person> persons; } class Person { String fname; String lname; } Then, the HTML I expect to have the Spring MVC tag libraries generate is like this: <form> <input name="persons[0].fn...

How to stop further request execution from inside a taglib?

Basically, we want to create a taglib that can possibly forward request execution to another page, similar to <jsp:forward />. How can we prevent the rest of the JSP page from executing from within the taglib? ...

How to define an example in a JSP taglib <tag-file> element?

I'm currently writing a bunch of JSP tags for our designers to use. In my .tld file I have some <tag> and many more <tag-file> elements. Now, I want to give the users of the tag library some examples about how to use them. According to Sun's documentation both <tag-file> and <tag> elements are allowed to have an <example> element. This...

Disable Struts 2.1 Dynamic Attributes

Is there any configuration option which can be used to disable the dynamic attributes feature in Struts 2.1? I use an older webserver which does not support dynamic attributes. Ideally I'm hoping for an alternative DTD or a configuration option in struts.xml ...

Enable checkbox B only when checkbox A is enabled and the other way around.

I have a two columns of checkboxes with predictable names. How can I disable a checkbox in column B when the ones in column a is unchecked and only enable it when the first the checkbox a is enabled? <dmf:checkbox name="someNameAColumnNumber" value="true" onclick = "enableColumnBCheckBox" runatclient="true" /> Is there somethi...

Redirection from jsp:include page

I want the user to be redirected to Login.jsp if the "role" stored in Session Scope doesn't match with the Request Parameter "accessRole" HomePage.jsp <jsp:include page="Header.jsp"> <jsp:param value="d" name="accessRole" /> </jsp:include> Header.jsp <c:if test="${sessionScope.role!=param.accessRole}"> <c:redirect url="Login.jsp"/> ...

jsp tag library changes checkbox name?

I'm trying to use a select all checkbox to select a column of checkboxes. So I gave all the ones I want checked off at once the same name ABoxesElement so that I can easily check them all on in javascript. However when I use firebug in firefox I can see that the checkboxes did not keep the name I gave them but pre-pended the component...

Printing a java scriptlet variable as if it is a JavaScript variable

hello i need to output a java variable inside a javascript call inside a tag inside a jsp ! for example: <% String param = "hello";%> <dmf:checkbox name="checkbox" onclick = "selectAll(<%=param%>)" /> the javascript generated is: selectAll(<%=param%>),this); but I actually want something like selectAllCheckBoxes(Hello),this);...

how to access a EL variable and pass it as an argument to a function in EL?

I want to call a function on a bean with an argument passsed to it in jsp using EL. The problem is it does not allow something like: "${teacherBean.certificationFor(${particularField})" the thing is i want to iterate over an array and call the function certificationFor for all the values in the array passed as an argument. I am getting ...

How to add custom VariableResolver to JSP Context in Jsp 2.0 to support special EL?

I'm building my own JSP Tag Library which need to support some features that Application developers can use like this: <w:user-label id="usrlb" value="${session.user}"/> <w:textbox id="tb" label="User Name" value="${usrlb.value.name}"/> which means I want my EL can interact with my Tag declaration. and also I need to add stack concept...

convert integer(long) to double in jsp

Hi, i want to do arithmetic operation on jsp . I am using struts tag lib tag following is the code : <s:set name="value1" value ="%{0.0}" /> <s:set name="value2" value ="%{0.0}" /> <s:set name="percent" value ="%{0.0}" /> <s:iterator> <s:set name="value1" value ="%{#value1+ someIntegerValue1}" /> ...

JSF Custom Image Component Problem to display multiple Image

Created a Tag Library Descriptor File: <?xml version="1.0" encoding="UTF-8"?> <taglib version="2.0" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd"> <tlib-version>1.0</tlib-version> <short-name>im...

JSTL: iterate list but treat first element differently

Hi Everyone I'm trying to process a list using jstl. I want to treat the first element of the list differently than the rest. Namely, I want only the first element to have display set to block, the rest should be hidden. What I have seems bloated, and does not work. Thanks for any help. <c:forEach items="${learningEntry.samples}...

How to access request in JspTags?

I want to call request.getContextPath() inside a JSP tag which extends SimpleTagSupport, is there any way to do it? ...