Win a copy of Rust Web Development this week in the Other Languages forum!

Trevor Price

Greenhorn
+ Follow
since May 19, 2006
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 Trevor Price

Originally posted by Bear Bibeault:
If you don't want to have distinct values in the web.xml for each server (automated building with Ant makes this easy), you could use properties files.



I was thinking that I might need to learn Ant to pull this off, but since I've never used it I was trying to find an easier way.

Thanks Bear.
15 years ago
JSP

Originally posted by Bear Bibeault:
Why have two values? Detecting upon IP address is fragile and not a robust way to deal with the issue.

Rather, have a single value that is set appropriately for each server.



Well, for further clarification, these are Google Maps keys, and Google validates the key against the address in the Address bar. For example, if I am browsing at http://localhost:8080/app/, then the JSP needs to pull the localhostKey; if I push the app to another server, then I'll be browsing to http://10.10.10.10:8080/app, and I'll need to use the testKey.

Ultimately, what I'm trying to do is have the key value set dynamically based on the server upon which the application is residing, without having to modify the code each time I push a WAR file to the server. I'm just not sure of the best approach.
15 years ago
JSP
Let me explain my current approach for this:

I'm storing some values in web.xml:


In my JSP, I need to pull a key using application.getInitParameter("testKey") or application.getInitParameter("localhostKey"), depending on the server environment.

My question is, how do I detect the server's IP address? Right now, I'm using testing for (request.getRemoteHost().equals("127.0.0.1")), which lets me know I'm on my local environment. But how would I know information about the remote environment?
15 years ago
JSP
I've been adjusting the response buffer with setBufferSize(), but I'm wondering if someone can let me know what a good size is? Is it an art form or is there a science to it, or somewhere in between?

My scenario is as follows:

Due to certain legacy code and other issues in this servlet, I must output thousands of lines JavaScript. That means lots of . In fact, the final output approaches 1 meg in some cases. This is mostly an intranet application, so download/upload speeds should be fairly decent. However, some people will be accessing it from an external broadband connection.

Is setBufferSize(100000) too high? What kinds of things do I need to consider here?
15 years ago
Found the problem by setting timers all over the place. The cache had nothing to do with it. I had set a very small response buffer size and was outputting lots and lots of code, which takes a long time over an Internet connection.

Which leads me to another question...
15 years ago
I am using ehcache to store a complicated object in memory the first time somebody hits the servlet. It takes almost 20 seconds to build.

When I do local testing, any return hits to the servlet pull the object out of cache instantly. However, when I upload the WAR file to a remote server, the server spends a long time doing who knows what, then it dishes out the HTML. My object appears to be pulled from the cache, but it just takes about 40 sec.

Strangly enough, if I use this remote server directly (ie, I am physically at the machine), the object is pulled from the cache instantly as it should.

Why is this behaving differently on a remote connection as opposed to a local connection?

I'm using Tomcat, btw.
[ June 22, 2006: Message edited by: Trevor Price ]
15 years ago
I originally posted this as a beginner Java question, but I guess it's really JSP specific. Nobody responded, so I thought maybe my information was incomplete. I've made it more informative.

Anyway, when I test my application locally, I can pull variables I've set in my web.xml file under the <context-param> sections and put them into my JSPs, e.g.

However, when I FTP my WAR file onto my hosted site, the same getInitParameter() method call returns null. What am I doing wrong? It is the cheapest Java hosting I could find, so it's a shared JVM and IP, etc. Is this having an effect on the application object? I'd really appreciate a response and please pardon the re-post.
15 years ago
JSP
When I test my application locally, I can pull variables I've set in my web.xml file under the <context-param> sections and put them into my JSPs, e.g.

However, when I ftp my WAR file to my hosted site, the same getInitParameter() method call returns null. What am I doing wrong?
15 years ago
JSP
I'm not sure on how to do this either, but I know there are ways to group your application into a single JAR file, which can run a main() method when the user double-clicks it. Of course, the user needs to have JRE installed on their system.

If you're thinking of an app that can run on any computer, there might be a way to include a small JVM somehow. This is beyond my understanding, though. It might give you some ideas of what to explore.
15 years ago

Originally posted by Jaap Vermeer:

<hr></blockquote>

This is not a very efficient way to put a tree in a database. A better way (in some respects, not all) is this:

No data redundancy. It could be a bit harder to build a tree from this, though.[/QB]



Yeah, that's actually how it's stored. The SQL query that I'm using is joining tables through parent-child relationships so that it looks like the first resultset.
15 years ago
Sorry, should have been more clear. By "fast", I mean "optimized", i.e., parsing 7000 nodes is hitting my server hard for about 6 seconds. Ultimately, I'm going to need to be able to manipulate the data in multiple ways. Maybe Enumeration isn't the most optimized code for this.

For example:

-----OR-----
15 years ago
Say I have a very large tree structure (7000+ nodes) and I need to parse it. What's the fastest way to accomplish this? I've been toying with the code below, but it's just too slow.

15 years ago

Originally posted by Ernest Friedman-Hill:


It's not? Why?



Because as I loop through the SqlRowSet, I would be duplicating each grandparent node several times, and also the same with parent nodes.

I could do a check to see if a given grandparent/parent node already exists (I
suppose a HashMap <String, DefaultMutableTreeNode> would work), then if it doesn't exist I would create it.

Say:


However, I'm looking at a tree containing several layers, and maybe over 7000 nodes in the end. This seems like a very inefficient way of populating it.
15 years ago
Hello

Right now I'm working with a SQL query that's returning a series of parent-child joins, something similar to the following:

Maybe this is more of a beginner question, but how can I use a SqlRowSet to parse these rowsets and build a tree model? I'm totally lost on where to even begin.

I'm thinking of looping through the rowset like this, maybe:


...but of course it's not going to be that simple. Has anyone else worked with something similar to this?

Thanks in advance.

[ May 22, 2006: Message edited by: Trevor Price ]
[ May 22, 2006: Message edited by: Trevor Price ]
15 years ago
Hmm, I'll have to look into this more then. I somewhat casually dismissed it. Thanks.
15 years ago