I am sure this is addressed in a million places on the net but this is my blog, so there. Simply set the 'nocache' property to 'true' on the 'controller' in struts-config.xml (I am using Struts 1/classic).
[todo: add the example XML and the example HTTP Response before/after]
I strongly encourage Java client/server/web technologies.
However, scripting languages continue to have a significant place in the market. Will Java be replaced? or will they live happily together?
Tuesday, June 2, 2009
Wednesday, May 27, 2009
JFreeChart and Time-based Bar Charts
Ok... I do not get many comments on my posts (because they are short and boring) but am really looking for people to comment on this one because I am looking for feedback.
I have used CeWolf/JFreeChart for about two years now (off and on). If someone asked me to rank my knowledge of them (1 to 10) I would answer 5 - not an expert, not a novice. Recently, it has become common for my users to want time-based charts. It seems that JFreeChart does not provide much utility for building bar charts based on time series. Am I seeing this correctly? or am I failing to understand a fundamental concept of JFreeChart? (or... other?)
Any feedback?
I have used CeWolf/JFreeChart for about two years now (off and on). If someone asked me to rank my knowledge of them (1 to 10) I would answer 5 - not an expert, not a novice. Recently, it has become common for my users to want time-based charts. It seems that JFreeChart does not provide much utility for building bar charts based on time series. Am I seeing this correctly? or am I failing to understand a fundamental concept of JFreeChart? (or... other?)
Any feedback?
Tuesday, May 5, 2009
Modify Windows Services Configuration
This is mainly for my reference, but I wanted to modify the description associated with some Services in my installation of Windows. I found the following website the most helpful... I am sure there are more:
http://www.opssys.com/instantkb/article.aspx?id=10576&cNode=7G3A2L
I used the following two lines to do what I wanted:
sc query state= all | findstr "DISPLAY_NAME STATE" >svc.txt
sc description {service_name} "description_goes_here"
http://www.opssys.com/instantkb/article.aspx?id=10576&cNode=7G3A2L
I used the following two lines to do what I wanted:
sc query state= all | findstr "DISPLAY_NAME STATE" >svc.txt
sc description {service_name} "description_goes_here"
Force Displaytag Export to Text
When I was using displaytag to export to excel, one of my columns contained text which was being recognized as numeric (scientific notation). When googling for a possible solution, seems like a LOT of people have had this problem in various ways (displaytag or otherwise). Thanks to this webpage, my solution was to write the following column decorator:
I have not run into any issues with this approach yet. If you do, I would appreciate a comment back. Thanks again to the guy who posted the hint that I reference previously.
p.s. Someone also suggested that I prepend the text with a unicode non-breaking space (see code following). Visually, it has the desired effect but it also modifies the text in the field so I do not like the solution as well. I just offer that solution to those who might want to use it.
I have not run into any issues with this approach yet. If you do, I would appreciate a comment back. Thanks again to the guy who posted the hint that I reference previously.
p.s. Someone also suggested that I prepend the text with a unicode non-breaking space (see code following). Visually, it has the desired effect but it also modifies the text in the field so I do not like the solution as well. I just offer that solution to those who might want to use it.
Tuesday, April 14, 2009
Crystal Reports IllegalStateException
So, my companies web app was throwing this nebulous IllegalStateException exception (see stacktrace below) that did not seem to adversely affect the application but I just couldn't let it go. I was able to resolve it like this:
- First, I googled it... not much help in the first few pages other than telling me what I already knew. 'out' was being called after it had been commited/closed.
- Though I usually don't have to do this anymore, it finally dawned on me to look at the compiled JSP code. (This was legacy, pure JSP... no struts nor nothing.) We were using Tomcat 5.5 and Eclipse 3.3+ so my JSP class was in the 'work' directory of my Eclipse project. Sure enough, there were out.print("") in my compiled JSP class. Where were they coming from?
- We had no explicit out.print() in our JSP code, so just looking at where they were in the class and how our JSPs were constructed, it seemed a close correspondence to an out reference for every JSP directive (like @page, etc.)
- So, I googled this: illegalstateexception crystal tomcat
and came across this link http://www.forumtopics.com/busobj/viewtopic.php?t=126993&sid=2b09528912043e0fbe72e0a947dc300a which basically tells you to avoid line breaks between your JSP directives. - Problem solved.
|ESD|13:28:22,363|ERROR|Servlet.service() for servlet jsp threw exception [http-12080-Processor22|org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/esd].[jsp]]
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:607)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:196)
at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:125)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:118)
at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:179)
at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:116)
at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:76)
at org.apache.jsp.pages.reports.CrystalReportViewer_jsp._jspService(CrystalReportViewer_jsp.java:184)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)
Wednesday, April 8, 2009
Script your ODBC Data Sources (MySQL)
Ok... admittedly this has to do with Windows scripting and not Java nor Javascript but is something that affects many of my projects. If your computer needs ODBC Data Sources, you can script their creation (particularly useful for configuring new developers' computers).
This script should provide a fairly useful start to customizing your own version. I am going to assume that it is fairly self-explanatory but you can always post a response if you do not agree or have a question.
This script should provide a fairly useful start to customizing your own version. I am going to assume that it is fairly self-explanatory but you can always post a response if you do not agree or have a question.
'================================================================
' This script creates one or more ODBC Data Sources.
' Usage: >cscript crystal.odbc.test.vbs
'
' Notes:
' * Search for 'configure-here' for all customization options
'================================================================
Const HKEY_LOCAL_MACHINE = &H80000002
strPrefix = "winmgmts:{impersonationLevel=impersonate}!\\"
strComputer = "."
strSuffix = "\root\default:StdRegProv"
strObjRef = strPrefix & strComputer & strSuffix ': wscript.echo strObjRef
Set objReg = GetObject(strObjRef) 'The Set keyword is mandatory
DriverNames = Array("SQL Server", "MySQL ODBC 3.51 Driver") 'Generally, do not modify these
Drivers = Array("C:\WINDOWS\System32\SQLSRV32.dll", "C:\WINDOWS\system32\myodbc3.dll") 'Generally, do not modify these
'================================================================
' Configuration Section
'================================================================
Const Chosen = 1 'configure-here: Zero-based index into the following two arrays; i.e. which DB are you using
Const Server = "xxxwebtest" 'configure-here: the machine where the DB is hosted
Const Port = "3307" 'configure-here: the port where the DB is hosted
Const Uid = "root" 'configure-here: the username to the DB
Const Pwd = "admin" 'configure-here: the password to the DB
ConnectionList = Array("dbone", "dbtwo", "etcetera") 'configure-here: see Note 1 below
REM *** Note 1 *** This is the array of ODBC Names which you will be creating;
REM also is the name of the database which the odbc connects to
'=== End : Configuration Section ================================
for each connection in ConnectionList
wscript.echo "*** Start *** Creating ODBC Data Source: " & connection
' *** Step 1 *** Create new Data Source Entry in system folder ...\ODBC Data Sources
strKeyPath = "SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources"
strValueName = connection
strValue = DriverNames(Chosen)
call WriteToRegistry
' *** Step 2 *** Create Data Source configuration in new user-defined folder {connection}
strKeyPath = "SOFTWARE\ODBC\ODBC.INI\" & connection
objReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
' *** Step 2a *** Database
strValueName = "DATABASE"
strValue = connection
call WriteToRegistry
' *** Step 2b *** Driver
strValueName = "DRIVER"
strValue = Drivers(Chosen)
call WriteToRegistry
' *** Step 2c *** Server
strValueName = "SERVER"
strValue = Server
call WriteToRegistry
' *** Step 2d *** Port
strValueName = "PORT"
strValue = Port
call WriteToRegistry
' *** Step 2e *** UID
strValueName = "UID"
strValue = Uid
call WriteToRegistry
' *** Step 2f *** PWD
strValueName = "PWD"
strValue = Pwd
call WriteToRegistry
' *** Step 2g *** Trusted_Connection : SQL Server only?
strValueName = "Trusted_Connection"
strValue = "Yes"
' call WriteToRegistry
' *** Step 2h *** Description
strValueName = "DESCRIPTION"
strValue = "EditMeThroughRegEdit"
call WriteToRegistry
wscript.echo "*** Finished *** Creating ODBC Data Source.\n"
next 'connection
'===== End of Script =====
'================================================================
' Subroutines and Functions
'================================================================
Sub WriteToRegistry
Const debugDesired = false
If debugDesired Then
wscript.echo "Simulating name/value to: HKEY_LOCAL_MACHINE\" & strKeyPath & ": " & strValueName & "/" & strValue
Else
wscript.echo "Modifying name/value to: HKEY_LOCAL_MACHINE\" & strKeyPath & ": " & strValueName & "/" & strValue
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
End If
End Sub
Tuesday, March 24, 2009
iBATIS Parameter Maps (a.k.a my iBATIS brain f*rt)
Problem:
On a project using iBATIS, I was receiving the following stacktrace:
And this is the snippet of the parameter map that is significant:
Well, my project hardly ever used explicit parameter maps. Usually, statements used the parameterClass="" syntax. So, as you might already know, my syntax was terribly wrong. The correct syntax follows. The thing to note (at least for me) is that the order of the individual SET parameters must match the order given in the parameter map that you use.
On a project using iBATIS, I was receiving the following stacktrace:
And this is the snippet of the parameter map that is significant:
Well, my project hardly ever used explicit parameter maps. Usually, statements used the parameterClass="" syntax. So, as you might already know, my syntax was terribly wrong. The correct syntax follows. The thing to note (at least for me) is that the order of the individual SET parameters must match the order given in the parameter map that you use.
Monday, March 23, 2009
Animate Your Page During Confirmation
Problem:
I desired the following feature on my page. When the user clicked a link, do the following:
Solution: yourpage.jsp
A slight improvement; do not begin the navigation until the last animation is finished:
snippet: yourpage.jsp
I desired the following feature on my page. When the user clicked a link, do the following:
- Use scriptaculous animations to "get rid of" the current page (goal is to eliminate other links and form submit buttons and provide visual feedback that a 'process' has started).
- Display the dialog that was *already* coded into the link's onclick event.
- If they choose 'ok', give them visual feedback that the action has been submitted and then *continue* to the link destination.
- If they choose 'cancel', restore the page.
Solution: yourpage.jsp
Event.observe( window, 'load',
function() {
//alert('observing window load');
$$('.processRole').each(
function(value, index) {
var old = value.onclick;
value.onclick = function() {
new Effect.SlideUp('pagecontent', {
duration: 1.0,
queue: 'front'
});
new Effect.Fade('copyRight', {
duration: 1.0,
queue: 'end',
afterFinish: function(o) {
var rv = old.call(value);
if (rv) {
// alert('you chose ok');
new Effect.Appear('waitNotification', {
queue: 'end'
});
new Effect.Highlight('waitNotification', {
queue: 'end'
});
new Effect.Appear('copyRight', {
queue: 'end'
});
location.href = value;
} else {
//alert('you chose cancel');
new Effect.SlideDown('pagecontent', {
duration: 1.0,
queue: 'front'
});
return false; // this return doesn't have any effects currently
};
}
});
return false; // always return false
};
}
);
}
);
A slight improvement; do not begin the navigation until the last animation is finished:
snippet: yourpage.jsp
new Effect.Appear('copyRight', {
queue: 'end',
afterFinish: function(o) {
location.href = value;
}
});
//location.href = value;
Tuesday, March 17, 2009
iBATIS Datasource Configuration (plus Spring)
On a project, we originally used iBATIS "raw" and had the prototypical datasource defined like this:
Upon improving our application architecture to use true DAOs, we concurrently upgraded to use Spring DI in our web app and subsequently took advantage of using Spring 'template' wrappers. However, changing the configuration was quite a lesson learned on my part:
Step 1: Remove transactionManager from iBATIS
Step 2: Create new 'datasource' bean using Spring
Step 3: Create new Spring-wrapped SqlMapClient using new 'datasource' bean
Upon improving our application architecture to use true DAOs, we concurrently upgraded to use Spring DI in our web app and subsequently took advantage of using Spring 'template' wrappers. However, changing the configuration was quite a lesson learned on my part:
Step 1: Remove transactionManager from iBATIS
Step 2: Create new 'datasource' bean using Spring
Step 3: Create new Spring-wrapped SqlMapClient using new 'datasource' bean
Thursday, March 12, 2009
Struts Multibox
This is going to be a useless post if I do not remember to get back to this, but I created a rather elegant way of doing checkboxes in tables (displaytag none-the-less) so that Struts 1.x actions could easily get the objects to which they refer.
Stay tuned...
Stay tuned...
Thursday, January 22, 2009
"More" Dynamic Forms with Struts
The goal behind this pot-pourri of code snippets is that I had a
spreadsheet-like form whose purpose was to collect information that was
relative to the time/date when the form was being viewed (i.e. "dynamic").
Hopefully, someday I will get the time to cohesively explain the relationship
between the code snippets but they should prove of some value in the meantime.
Thanks to the following website for providing a converter for my html and xml text: http://www.felgall.com/htmlt47.htm
spreadsheet-like form whose purpose was to collect information that was
relative to the time/date when the form was being viewed (i.e. "dynamic").
Hopefully, someday I will get the time to cohesively explain the relationship
between the code snippets but they should prove of some value in the meantime.
Thanks to the following website for providing a converter for my html and xml text: http://www.felgall.com/htmlt47.htm
Subscribe to:
Posts (Atom)
VisualVM on Windows with SDKMAN
7/31/2024 - I have been using SDKMAN on Windows via Git Bash for some time now and truly like it. I did however come across an interesting...
-
7/31/2024 - I have been using SDKMAN on Windows via Git Bash for some time now and truly like it. I did however come across an interesting...
-
Ok... I do not get many comments on my posts (because they are short and boring) but am really looking for people to comment on this one bec...