Scott Escue

Ranch Hand
+ Follow
since Jan 20, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Scott Escue

Thanks, Bear, that was meant to be a call to setCharacterEncoding. Once I fixed that I noticed that the result of responseXML.documentElement went from null to an empty string (it's been an empty string all along in the original code). That prompted me to try outputing the nodeName of the document element for grins and much to my surprise, and embarrassment, it was "ajax-response".

So it seems my problem for the last day has simply been my own ignorance. I was expecting the output of responseXML.documentElement to be "[Object object]", or at least something other than an empty string. Thanks to you both, though, for helping me realize where I was going wrong.
[ November 05, 2008: Message edited by: Scott Escue ]
Thanks, Eric. Indeed it should. It's correct in the original code; I messed it up when I created the simplified example. Unfortunately "request.responseXML.documentElement" returns null. I also checked the "responseXML.parseError" and got a value of 0, which should indicate there were no parsing errors.
I'm attempting to use prototype to make an AJAX request to a server-side component that returns valid XML. Everything works as expected with one exception, the responseXML property of the XmlHttpRequest object is not being populated. The responseText property is populated with the text of the XML document, but I need the XML document object that should be available through responseXML. The problem is happening in IE 7. I've tried thiss with Firefox and it works fine, i.e. responseXML is populated. I'm not sure if there is a problem with the response I'm sending or if this is an IE issue. From all that I've read, responseXML should be populated automatically, even in IE, as long as the contenttype header in the response is set to "text/xml" and the XML itself is well-formed. If anyone has any insight or suggestions, I would greatly appreciate the help.

Here is the code from doGet method of the servlet that is sending the response:


The source for the HTML page that makes the request is below:


The xml that comes across is, not surprisingly,:



Thanks,
Scott
[ November 05, 2008: Message edited by: Scott Escue ]
Paul,

I had the same idea for an upcoming project at work. I did some googling a while back and found this article describing how to use Winstone as the embedded container. http://www.itmill.com/articles/Packaging_web_applications_for_desktop_use.htm I think Winstone only provides the servlet container but there are instructions on their Sourceforge page for integrating Jasper to handle JSP content. I don't know if this would help you out with the static content or not. I don't recall reading anything in either direction about it being handled.
I've not had a chance to try any of this, so consider this a disclaimer I'd be interested to know if you have any success getting this to work regardless of which embedded container you end up using.
15 years ago
Arjun,

Where exactly is your HelloWorld.class file located on disk? Is it physically in the "..\Users\Ravi\Desktop\CurrentProject\Servlets" directory? If it's not actually within the your application's WEB-INF folder this is not going to work.
15 years ago
Amit,

Looking up the DataSource once and caching it is definitely a good idea since, as you mentioned, it saves you from doing a JNDI lookup each time you need to use it. A couple of things you may want to consider about it:

1) You need to make sure the DataSource implementation your using is thread-safe. If your using an implementation provided by your database vendor, say Oracle or MySql, it's probably safe to assume thread-safety has been taken care of. Of course it never hurts to verify that!

2) If you store the DataSource in the ServletContext you will be forced to retrieve the DataSource in your servlet/controller layer and pass it through to any business/DAO methods that need to actually use it. If you have a very simple application maybe that's not a big deal for you. But you can use a service locator to get the same result of looking up the DataSource once and caching it. The advantage is that the service locator can be used in any layer of your application to retrieve the cached DataSource, which keeps you from having to pass a DataSource argument to each method that needs to use it.
http://java.sun.com/blueprints/corej2eepatterns/Patterns/ServiceLocator.html
[ April 01, 2008: Message edited by: Scott Escue ]
15 years ago
Danush,

Can you post the code from your servlet? Setting the Content-disposition header to inline is working for me in both IE7 and Firefox2.
15 years ago
Take a look at your Tomcat logs, I believe you may be getting any error when Tomcat tries to start your webapp.

Take a look at your web.xml. The SchemaLocation url in your opening web-app tag is slightly off:
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2.4.xsd"

should be:

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
[ April 20, 2007: Message edited by: Scott Escue ]
16 years ago
Peter,

I agree with you, I don't believe the private declaration is an issue here. If you removed the abstract modifier from TestNested and the static modifier from nested this would work with the existing access modifiers.

I know that it's extremely frustrating (actual sentiment censored for this forum) when behavior changes between compiler releases, but in IMO the way 1.6 treats this code seems consistent with the way other instance members are treated when you attempt to access from a static context. We've all seen the "method cannot be accessed from static context" errors when we first starting learning java and tried to access an instance method from within main without having an instance. This seems to be the exact same thing, only with an instance class instead of an instance method. It's just unfortunate that this has been allowed for so long, and now changing it is obviously breaking people's code.
16 years ago
This really has absolutely nothing to do with java, but... you can open a new shell within an existing cmd prompt and give it a custom title using start "<title>"
16 years ago
Paul,

A Google search links to several articles, including this one, where people encountering the same problem had to reinstall their JVM and customize the installed character sets.
[ April 19, 2007: Message edited by: Scott Escue ]
16 years ago
Manish,

I'm having a little bit of trouble following what you say is happening. If I understand correctly you're saying the method you posted is working as you expect, so when you print the result of your format you get the correct MST time.
But when you parse the result of this formatted string back into a Date object and then print the Date, you get the time from your timezone. Is that correct?
16 years ago
Amir,

Took a look at this explanation of the Decorator Pattern. It's hard to say without knowing what you're trying to achieve, but this may help.

And to answer your original question, no. I don't believe you can dynamically add members to your classes or objects in Java.
16 years ago
John,

I just recently got turned onto Prototype myself. I found the three articles on the Tips and Tutorials page very useful, and also very easy to follow. I'm sure you'll want to take a look at the Ajax article, if you haven't already, but I highly recommend you read How Prototype Extends the DOM as well. It's a quick read but goes a long way towards explaining Prototype.
Eric,

You should be able to refactor this in the GUI builder without too much trouble. Just add several JPanels to whatever container is giving you trouble and move some of your components onto the sub-panels. There shouldn't be any need to modify the initComponents method by hand.
16 years ago