jsp-tags

Importing JavaScript in JSP tags

I have a .tag file that requires a javascript library (as in a .js file). Currently I am just remembering to import the .js file in every JSP that uses the tag but this is a bit cumbersome and prone to error. Is there a way to do the importing of the .js inside the JSP tag? (for caching reasons I would want the .js to be a script impo...

How do i pass an object to a JSP tag

I have a JSP page that contains a scriplet where i instantiate an object. I would like to pass that object into 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 dir...

JSTL collection iteration

Hi, I have a java bean like this: class Person { int age; String name; } I'd like to iterate over a collection of these beans in a JSP, showing each person in a HTML table row, and in the last row of the table I'd like to show the total of all the ages. The code to generate the table rows will look something like this: <c:forEa...

Java constants in JSP

Hi, I have a class that defines the names of various constants, e.g. class Constants { public static final String ATTR_CURRENT_USER = "current.user"; } I would like to use these constants within a JSP without using Scriptlet code such as: <%@ page import="com.example.Constants" %> <%= Constants.ATTR_CURRENT_USER %> There appea...

WebSphere App Server Not Compiling JSP/Tag Libs

Hello This is a problem that only occurs on application update (only tested through Admin Console, not CLI). Also, this is only happening on our development environment, which is identical to our prod env. On uninstall/install, everything is compiled properly. However, this is a large application and it takes long enough to do an upd...

JSP custom tag library

HI.. I m creating a Jsp custom tag, that should take an array object in the custom tag and it should display the elements of the tag in the HTML table form. Do anyone have the suggestion kindly helpful. Thanks and regards. Vinayak ...

Struts JSP previous link

Hi, Does anyone know how I can retrieve the previous JSP URL that a page has come from within a JSP? Can I retrieve this from the session/ request/ response object? Hope this makes sense, Thank you ...

JSP struts

Hi, How would I assign a variable within scriplet code in JSP <%> and then use struts logic tags to do stuff based on the value of the variable assigned in the scriplet code block? I have tried using struts:logic equal and greaterthan to no avail.... Many Thanks, ...

JSP custom tag library (Passing Attributes)

I m passing multiple attributes in my custom tag like &lt mytag Firstname="Thadeus" Lastname="Jones" &gt Then how would I access the individual attributes in the TagHandler class.. Kindly specify any suggestions.. Regards, Vinayak ...

JSP custom tag library (Unable to find setter method for the attribute)

I'm having trouble with a custom tag:- org.apache.jasper.JasperException: /custom_tags.jsp(1,0) Unable to find setter method for attribute : firstname This is my TagHandler class: package com.cg.tags; import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.tagext.TagSupport; public class N...

declare JSP taglib directives in web.xml

Hi, I seem to remember reading that it's possible to declare taglib directives such as: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> in web.xml. This eliminates the need to duplicate this directive in every JSP file where the taglib is used. Could someone tell me how these directives can be added to web.xml? Chee...

JSP Custom Tag Library vs JSP2 Tag Files

Can anybody gimme the idea about the JSP custom tag library and the JSP 2 Tag files.. Are this two are alternatives to use....??? If there is any comparision(or merits and demerits) among this please do specify.. And which one of this is better to work with.. I m waiting for the kind suggestions.. Regards, Vinayak ...

JSP-tags with static output

I am considering creating some JSP-tags that will always give the same output. For example: <foo:bar>baz</foo:bar> Will always output: <div class="bar">baz</div> Is there any way to get a JSP-tag to behave just like static output in the generated servlet? For example: out.write("<div class=\"bar\">"); ... out.write("</div>"); i...

Using JavaScript within a JSP tag

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

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

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

jsp:forward in Java without using JSP tag?

Is there a pure-Java equivalent to <jsp:forward page="..." /> that I can use within a <% ... %> block? For example, I currently have a JSP page something like this: <% String errorMessage = SomeClass.getInstance().doSomething(); if (errorMessage != null) { session.setAttribute("error", errorMessage); %> <jsp:forward pag...

JSP bean tag for property that might not exist

In JSP I can reference a bean's property by using the tag ${object.property} Is there some way to deal with properties that might not exist? I have a JSP page that needs to deal with different types. Example: public class Person { public String getName() } public class Employee extends Person { public float getSalary() } In J...

indispensible JSP tag libraries

Hi, I'm interested to know what are the "must have" JSP tag libraries apart from JSTL. All I've found so far are ccc - for accessing static constants in JSP (without scriptlet) displaytag - for generating sophisticated HTML tables that includes data paging, grouping, sorting, exporting etc. What other indispensible tag libs are out ...

sorting HTML tables with displaytag JSP tab library

Hi, I'm using the JSP displaytag tag lib to create HTML tables. I'd like the user to able to click on a column header in order to sort the data. My JSP code is shown below: <display:table name="tableData" id="stat" sort="page"> <display:column property="name" title="Name" sortable="true"/> <display:column property="age" title="Age"...

JSP Tag Recursion

I am implementing a tree tag for one of my practice projects, where I would display the contents of a directory in the form of a tree (recursively). I had implemented a similar requirement as a Custom Tag in Java during the pre-JSP2.0 days. Handling a directory needs recursion (to handle the subdirectories)! Is it possible to code this a...