Programming


Programming21 Apr 2005 10:17 am

After a change in a JSP web application’s web.xml file to enable filters in the displaytag taglib, I needed to reload the web.xml file to make the changes live. There are a couple of ways to go about this: Restart tomcat or reload the web application or remove then reinstall the web application using the tomcat web manager. I chose to restart tomcat since for my setup I don’t have access to the web manager but have easy access to the stop and start .sh scripts. Either way works fine though.

del.icio.us:Reload JSP Tomcat Web Application web.xml File digg:Reload JSP Tomcat Web Application web.xml File spurl:Reload JSP Tomcat Web Application web.xml File wists:Reload JSP Tomcat Web Application web.xml File simpy:Reload JSP Tomcat Web Application web.xml File newsvine:Reload JSP Tomcat Web Application web.xml File blinklist:Reload JSP Tomcat Web Application web.xml File furl:Reload JSP Tomcat Web Application web.xml File reddit:Reload JSP Tomcat Web Application web.xml File fark:Reload JSP Tomcat Web Application web.xml File blogmarks:Reload JSP Tomcat Web Application web.xml File Y!:Reload JSP Tomcat Web Application web.xml File smarking:Reload JSP Tomcat Web Application web.xml File magnolia:Reload JSP Tomcat Web Application web.xml File segnalo:Reload JSP Tomcat Web Application web.xml File
Programming21 Apr 2005 10:10 am

One of my sites uses the displaytag taglib to format an Oracle result set. I recently tried to add on the export functionality to one of the pages but received this error:

Unable to reset response before returning exported data. You are not using an export filter. Be sure that no other jsp tags are used before display:table or refer to the displaytag documentation on how to configure the export filter (requires j2ee 1.3).

After doing some searching I found that there was not very much info out there but the solution is fairly simple and really is defined by the error message. You need to configure the export filter in your web.xml document. OK, but HOW do you do that? Below are the lines I added to my web.xml file to enable the displaytag export filters.


<filter>
<filter-name>ResponseOverrideFilter</filter-name>
<filter-class>org.displaytag.filter.ResponseOverrideFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>ResponseOverrideFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>

Then all I had to do was make sure that the JSP web application was reloaded in Tomcat. (See the other post on how to reload the web.xml file). This solution allows you to have JSP tags above your main displaytag table tag. This is very necessary in most applications which do preliminary processing, such as retrieving a dataset, checking login status, etc.

del.icio.us:JSP displaytag Excel Filter Error digg:JSP displaytag Excel Filter Error spurl:JSP displaytag Excel Filter Error wists:JSP displaytag Excel Filter Error simpy:JSP displaytag Excel Filter Error newsvine:JSP displaytag Excel Filter Error blinklist:JSP displaytag Excel Filter Error furl:JSP displaytag Excel Filter Error reddit:JSP displaytag Excel Filter Error fark:JSP displaytag Excel Filter Error blogmarks:JSP displaytag Excel Filter Error Y!:JSP displaytag Excel Filter Error smarking:JSP displaytag Excel Filter Error magnolia:JSP displaytag Excel Filter Error segnalo:JSP displaytag Excel Filter Error
Programming05 Mar 2005 05:24 pm

The problem: Display tag sorts all values as Strings which means that date values are sorted incorrectly by displaytag. One way to do this is write your own decorator class which implements a sort for dates and use this decorator on your field.

A quick and easy way to sort date items correctly without having to write your own decorator class is to: change the date format to yyyy/mm/dd This is a date display which correctly sorts in string representation. It is that easy.

If you want sort your list by any colum by default you can specify the column index of the column you want to sort in the defaultsort=”” attribute of the table tag. The default order can be set using the defaultorder attribute: the default value is ascending, you can set it to descending to reverse the order. So, to sort by default your date column, set defaultsort equal to the column index of the date column (remember 0 based indexing) and then set defaultorder=”decending” so you have most recent dates first.

del.icio.us:An easy way to correctly sort date fields in Java displaytag digg:An easy way to correctly sort date fields in Java displaytag spurl:An easy way to correctly sort date fields in Java displaytag wists:An easy way to correctly sort date fields in Java displaytag simpy:An easy way to correctly sort date fields in Java displaytag newsvine:An easy way to correctly sort date fields in Java displaytag blinklist:An easy way to correctly sort date fields in Java displaytag furl:An easy way to correctly sort date fields in Java displaytag reddit:An easy way to correctly sort date fields in Java displaytag fark:An easy way to correctly sort date fields in Java displaytag blogmarks:An easy way to correctly sort date fields in Java displaytag Y!:An easy way to correctly sort date fields in Java displaytag smarking:An easy way to correctly sort date fields in Java displaytag magnolia:An easy way to correctly sort date fields in Java displaytag segnalo:An easy way to correctly sort date fields in Java displaytag
Programming21 Jan 2005 01:54 pm

I recently wrote some SQL INSERT scripts to add some information to a table I had created. The insert scripts were in a text file and I attempted to execute that text file in sqlplus with the @ directive. Everything ran fine but when it got to the “&” character, ORACLE prompted me for the new value from the command line. HUH?? I don’t want a new value I want the string I entered. I tried escaping out the & with a “\” but that just now put a “\” in.

PROBLEM: How to insert a “&” character into a string in ORACLE sqlplus without being prompted to reenter the value.

SOLUTION: Place this command at the top of your text file: set scan off; This turns off the ORACLE defines and other similarly annoying features and allows your text file to run as you intended.

I am sure that ORACLE DBA’s would say well of course but being a simple software engineer and only using sqlplus when I have to this was quite the annoying little problem.

So why was I need to insert a “&” well I really needed to insert a “≥” and “≤” into the string so greater than equal (?) and less than equal (?) signs would be outputted to the browser in my web app. After I overcame the above problem, I thought I was home free but alas I also need to set this as the value of a radio button. When I used value=”≥” for my value Internet Explorer did just that and inserted the symbol instead of the string. So, when the greater-than-or-equal was passed through POST from the form, IE then converted it to another representation and by that time when I tried to insert it into the DB using JSP my prepared statement the whole thing would blow up. By blow up I mean that Tomcat would return some obscure error message which would be caught by my try{} catch{} and do me no good.

PROBLEM: How to pass a greater-than-or-equal symbol HTML representation (or other HTML entity) from ORACLE DB to a form and back successfully.
SOLUTION: I used the ISO-8859-1 decimal Code representation for the symbol. So instead of passing “≥” I passed ? which worked because IE did not convert it but would display the symbol as I needed.

This solution would also work if you need to display “≤” you could use ? and for any other symbol where the “&___” HTML format is needed. The moral here is good luck if you need to start passing HTML special characters as strings to and from a DB because the handling of those can be creative.

del.icio.us:ORACLE sqlplus   digg:ORACLE sqlplus   spurl:ORACLE sqlplus   wists:ORACLE sqlplus   simpy:ORACLE sqlplus   newsvine:ORACLE sqlplus   blinklist:ORACLE sqlplus   furl:ORACLE sqlplus   reddit:ORACLE sqlplus   fark:ORACLE sqlplus   blogmarks:ORACLE sqlplus   Y!:ORACLE sqlplus   smarking:ORACLE sqlplus   magnolia:ORACLE sqlplus   segnalo:ORACLE sqlplus
Programming04 Jan 2005 01:55 pm

Today I needed to create a new chromeless (no scrollbars, toolbarrs, navbars etc)
window and submit a form to it because we were directing users to another vendor’s
product who required information to be submitted via POST to their site to proceed.
Here is how I proceeded.

PROBLEM: How to submit a form to a new popup window.

SOLUTION: I modified the <form> target and onsubmit properties.
Non-JavaScript users will get a regular new window which works fine for our
application because at least they are not taken away from the site.

CODE:

<form name=”frmModule5″ id=”frmModule5″ action=”processingPage.jsp”
method=”post” target=”moduleFive” onsubmit=”window.open(‘about:blank’,
‘moduleFive’, ‘width=800,height=550,resizable=true,scrollbars=true’);”>

…. form elements here …

<input type=”submit” value=”submit”>

</form>

del.icio.us:Submit a form to a new popup window digg:Submit a form to a new popup window spurl:Submit a form to a new popup window wists:Submit a form to a new popup window simpy:Submit a form to a new popup window newsvine:Submit a form to a new popup window blinklist:Submit a form to a new popup window furl:Submit a form to a new popup window reddit:Submit a form to a new popup window fark:Submit a form to a new popup window blogmarks:Submit a form to a new popup window Y!:Submit a form to a new popup window smarking:Submit a form to a new popup window magnolia:Submit a form to a new popup window segnalo:Submit a form to a new popup window
Programming23 Dec 2004 09:03 am

Just FYI: ResultSetMetaData.getTableName(int col) is NOT implemented in ORACLE or many other JDBC’s for that matter. It seems Informix, I think, is the only one who actually implemented this function!!

Why would you need functionality this since you obviously performed the query in the first place so must have know which table(s) you were working with?

One, as in my case, you are writing a DB Admin tool and are dynamically displaying the returned Record Set and need to know which table was accessed to pass that to any other functions that need to alter that same table.

Two, you have performed a JOIN or nested SELECT and would like to know which table a particular item is associated with.

This function was just what I was looking for and would be useful if only it wasn’t a tease. Obviously the SUN JDK 1.4.1 people thought it was important to put in the spec and now we just need to get the DB developers to get on the boat.

del.icio.us:ResultSetMetaData.getTableName(int col) digg:ResultSetMetaData.getTableName(int col) spurl:ResultSetMetaData.getTableName(int col) wists:ResultSetMetaData.getTableName(int col) simpy:ResultSetMetaData.getTableName(int col) newsvine:ResultSetMetaData.getTableName(int col) blinklist:ResultSetMetaData.getTableName(int col) furl:ResultSetMetaData.getTableName(int col) reddit:ResultSetMetaData.getTableName(int col) fark:ResultSetMetaData.getTableName(int col) blogmarks:ResultSetMetaData.getTableName(int col) Y!:ResultSetMetaData.getTableName(int col) smarking:ResultSetMetaData.getTableName(int col) magnolia:ResultSetMetaData.getTableName(int col) segnalo:ResultSetMetaData.getTableName(int col)
Programming23 Dec 2004 08:39 am

I recently dealt with this error in some JSP code I was writing and did not see much information out there on a cause and solution so here is what I found out.

I had already tracked the problem down to some code that should have been correct:

<display:column property=”<%=rsmd.getColumnName(i)%>” title=”<%=rsmd.getColumnName(i)%>    ”
sortable=”true” headerClass=”sortable” maxLength=”20″
/>

When I remove the after the the rsmd.getColumnName(i), it works correctly but when I add any other characters inside of the title value it fails.

The Problem: With the displaytag tablib you can not dynamically create strings from jsp and text inside of a key-value pair. You can place just JSP or just text inside the value but not the combination of both.
The Solution: Create a temporary String variable to hold the value you would like to place in the value pair and then only reference that string.

<% String columnTitle = rsmd.getColumnName(i) + ”    “;%>

<display:column property=”<%=rsmd.getColumnName(i)%>” title=”<%=columnTitle%>”
sortable=”true” headerClass=”sortable” maxLength=”20″
/>

Hope this helps someone else,
Richard

del.icio.us:jsp.error.attribute.unterminated digg:jsp.error.attribute.unterminated spurl:jsp.error.attribute.unterminated wists:jsp.error.attribute.unterminated simpy:jsp.error.attribute.unterminated newsvine:jsp.error.attribute.unterminated blinklist:jsp.error.attribute.unterminated furl:jsp.error.attribute.unterminated reddit:jsp.error.attribute.unterminated fark:jsp.error.attribute.unterminated blogmarks:jsp.error.attribute.unterminated Y!:jsp.error.attribute.unterminated smarking:jsp.error.attribute.unterminated magnolia:jsp.error.attribute.unterminated segnalo:jsp.error.attribute.unterminated

« Previous Page