Terry Chambers

Greenhorn
+ Follow
since May 11, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Terry Chambers

I have built a JSP that can query a database using JDBC and retrieve a ResultSet. I can iterate through that set and display the data out on the page.

I do not want all the Java code exposed on the JSP so I have moved it to a class.

Now I am unsure what is the best method to get the "ResultSet" so that I can display it on the page.

Since a ResultSet object requires executing a Statement, I can't see that I can create a ResultSet object in my JSP code.

I have created a method in my class called "getResultSet". It is current set to a "void" return type.

What is the best way to expose the results of the ResultSet object so that I can access the rows and data elements contained in it, from the JSP?

Do I need to create an object to hold the data from each row and then just create multiple objects? If yes, I am still unsure how I would get the items to display in the HTML of the page.

Thoughts? Advice?

13 years ago
JSP
Thanks to you both. I'll go back and look at how I am approaching this problem.
Situation:

I have a database query to complete which will return a result set that I will then parse through and retrieve the values from the set.
I have created a class called "obQuery". As part of the constructor, I am generating the objects to create the query and then have created a method called "getResultSet", within the main class, that generates the "ResultSet" object from the SQL statement.

When I instantiate the "obQuery" object, I'd like to be able to retrieve the results of the ResultSet. I am lost though because, if I call the "getResultSet" method, that method has to know which SQL statement to run and the calling code does not know that value.

How can I create an empty ResultSet object and populate it with the output of the "getResultSet" code, without having to pass in the values to the method?

Sorry, I guess that is important.

I was thinking of a command line application as it will be run on a schedule.
14 years ago
I have an XML file that I need to be able to upload, via HTTP POST, to a known URL which will accept the file and process it.

I am not sure of the process that I need to take. For example, to "upload a file", do I need to read the file in line by line and then upload it line by line or is there a way to just specify a local file and then upload it?

If you can give me some direction, that would be great.

Thanks
Terry
14 years ago
I have a string of text:

word 1 1 4.0 text 1 2 3.5 dog 3 4 1.0 walker 3 2 4.0

The pattern is:

|<word> <number> <number> <number.number>| |<word> <number> <number> <number.number>| |<word> <number> <number> <number.number>|

I want to be able to take this string of text and break it down into tokens, just like the String Tokenizer does. However, I can't seem to figure out how to do it since I can't break it down by white space (although, I guess I could tokenize and then count to see if it is the 4th item to determine if I should do something different.

What is the most efficient way to handle this?

Thanks
14 years ago

Ok, well, that was way too easy.

Thank you for that.
14 years ago

I have an XML file which is stored using an object called "Config". When "Config" is instantiated, it reads the XML file and creates "Server" objects.

In my JSP I want to be able to access some "get" methods associated to the "Server" objects so I have created a Config object and then used a method called "getServers" which creates a List of "servers" to get access to the "Server" objects.



I want to be able to work with those "Server" objects by loading them up in objects in the JSP but the "get" method of "List" returns "Object" types and so the above statement returns an error that I cannot convert from "Object" to "Server". How can I convert/cast this properly so that I can access the "get" methods of my Server objects?

Thanks
Terry
14 years ago
There has to be a simple answer to this ...





When value of "number" displays, it is always 0.0, even if I replaced "Served" and "Max" with the actual numbers.

Why is it not printing the value of the division?
14 years ago

Do you need to provide a default attribute to the project tag?



Yes! That was all that was missing.

Thanks!
14 years ago
I went to a Command prompt and into the directory where the build.xml is and just typed "ant". I received back "BUILD Successful" with a time of 0 seconds. Nothing was created or deleted.

Should I uninstall Eclipse and reinstall it?
14 years ago
Hi - I'm having trouble with my Eclipse 3.3 IDE.

I have an ANT build file that is very simple yet it is not working.



When I run the build using RUN AS/ANT BUILD, the process says the BUILD was successful but directories, in the project, are not deleted not created. It is as if nothing is actually happening but there are no errors.

I am using Vista and my Eclipse Workspace directory is under my user directory.

I have searched the entire computer for the WAR file to see if maybe it is creating it somewhere else but it is not found.

I have no idea what is going on. Any thoughts?

Thanks
Terry
14 years ago
Thanks for the advice. The basic concept was too simple and the books made it more complex than it needed to be.

I've got it.
14 years ago
I need a little guidance on a Java problem I am tackling. I hope you can spare a moment for some advice.

I am working with a server that outputs some complex XML over http(s). By complex I mean that a lot of the items contain attributes.

I have a need to build a servlet that will be able to receive this XML content via http(s) and then be able to apply a given XSLT against it, which creates HTML output.

I am reading through a book called "Java and XSLT" (O'Reilly) which provides examples, but they also use very small XML files that are simple and usually created by the user via a web page.


At a high level, I believe the approach is to simply:

Fetch a given URL and store it as an XML object.
Load an XSLT file into memory.
Apply the XSLT to the XML and then display the results back to the user.


Can you help me fill in the gaps of what else I would need to do. I don't know if I need to create classes to for each of the XML elements in the XML file. In the examples I am seeing, it seems that is what they are doing.

Thanks for any advice you can offer.

Terry
14 years ago