How to set the row id [ TR ] and column id [ TD] in displaytag?

First, I do not believe it is possible to set the ids on the td’s or tr’s in displaytag without modifying the source. This has not left my list of things to do, but for now I have a work around for you.
Instead of defining your table:
 id='row' name="..." export="true" requestURI="">
property="usefulData" title="Useful data" sortable="true" />
... more columns ...
do this:
 id='row' name="..." export="true" requestURI="">
title="Useful data" sortable="true" >
id='${row.usefulData}' class='css_class_selector'>${row.usefulData}

Note the span wrapping the printed data. Now you can select the data relating printing inside your table, which is probably what you want; to select your data, as opposed to specifically selecting the td’s and tr’s.

Accessing a value in Struts ActionForm from JSP

Try
<h1>Hello  <bean:write name="RegistrationForm" property="userid" />!</h1>
it doesn’t matter what the internal name / coding of your formbean is. All what matters is how the getters and setters are named. Your getter is named getUserid() to the javabean property is userid.

How to evaluate a scriptlet variable in EL?

So you want to evaluate a scriptlet variable in EL? Store it as a request attribute.
<%
String var = "some";
request
.setAttribute("var", var);
%>

<c:if test="${param.variable1 == 'Add' && var == 'some'}">
However, this makes no sense. You should avoid scriptlets altogether and use JSTL/EL to prepare this variable. So if you make the functional requirement more clear, e.g. “How do I do this (insert scriptlet code snippet) using JSTL/EL?”, then we’ll be able to suggest the right approach.

See also:

difference between page and request

hi,
Page Scope is the smallest scope, and is a representation of the PageContext object for your JSP. Each JSP has it’s own page scope, so objects in the page scope of one JSP are not accessible to other JSPs. This is sorta like making a private variable in Java.

Request scope is the next smallest scope, and is represented with the JSP’s request object. All JSPs and servlets that share a request share the request scope. For example, if I have a JSP that forwards to another page, and that second page includes a third JSP page, then all three pages are in the same request, and can share objects through the request scope. A special note here, is the response.redirect(), will create a new request, unlike forwards and includes. Also note, a new request is made every time the user gets a new page, be it by clicking a link, a button, or some JavaScript call.

http://www.coderanch.com/t/291025/JSP/java/difference-page-request

Posted in jsp

The ternary operator and JSP

This interesting bit of JSTL for JSP is worth writing about.
Background: The ternary operator allows you to combine an if-then-else statement into one line using a bunch of symbols. It makes code a bit harder to read, but it also makes it look cool.
I can turn this:


not empty


empty

into this:

It even parses variables for output:

And you don’t even need the c:out:
${not empty somevariable ?  somevariable: 'empty'}
Old hat yes, but I thought an interesting tidbit to write about!

Evaluate empty or null JSTL c tags

You can use the  or  for this.
 test="${empty var1}">
var1 is empty or null.

test="${not empty var1}">
var1 is NOT empty or null.
or

test="${empty var1}">
var1 is empty or null.


var1 is NOT empty or null.

The ${not empty var1} can also be done by ${!empty var1}.
To learn more about those ${} things (the Expression Language, which is a separate subject from JSTL),check here.

Difference between JSP include directive and JSP include action

  •   is the JSP include directive.
    At JSP page translation time, the content of the file given in the include directive is ‘pasted’ as it is, in the place where the JSP include directive is used. Then the source JSP page is converted into a java servlet class. The included file can be a static resource or a JSP page. Generally JSP include directive is used to include header banners and footers.The JSP compilation procedure is that, the source JSP page gets compiled only if that page has changed. If there is a change in the included JSP file, the source JSP file will not be compiled and therefore the modification will not get reflected in the output.
  • is the JSP include action element.
    The jsp:include action element is like a function call. At runtime, the included file will be ‘executed’ and the result content will be included with the soure JSP page. When the included JSP page is called, both the request and response objects are passed as parameters.If there is a need to pass additional parameters, then jsp:param element can be used. If the resource is static, its content is inserted into the calling JSP file, since there is no processing needed.
Posted in jsp

Caching jsp pages on jboss

I found no relief from clearing out the browser cache or setting IE up to get new versions of pages everytime……BUT………………..

If you delete the contents under the “work” folder of the JBoss alias your running, all these JSP problems go away. I only see the current JSP pages that are actually deployed under the alias I’m running. No more old JSP data. That was really weird to me and was driving me nutts.

I deleted everything under C:\jboss-4.0.2\server\default\work

since I’m running the “default” alias.

https://community.jboss.org/thread/38118

Difference between JSP include directive and JSP include action

  • is the JSP include directive.
    At JSP page translation time, the content of the file given in the include directive is ‘pasted’ as it is, in the place where the JSP include directive is used. Then the source JSP page is converted into a java servlet class. The included file can be a static resource or a JSP page. Generally JSP include directive is used to include header banners and footers. The JSP compilation procedure is that, the source JSP page gets compiled only if that page has changed. If there is a change in the included JSP file, the source JSP file will not be compiled and therefore the modification will not get reflected in the output.
  • is the JSP include action element.
    The jsp:include action element is like a function call. At runtime, the included file will be ‘executed’ and the result content will be included with the soure JSP page. When the included JSP page is called, both the request and response objects are passed as parameters. If there is a need to pass additional parameters, then jsp:param element can be used. If the resource is static, its content is inserted into the calling JSP file, since there is no processing needed.

http://javapapers.com/jsp/difference-between-jsp-include-directive-and-jsp-include-action/

Posted in jsp