Tom Joiner

Ranch Hand
+ Follow
since Sep 19, 2006
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 Tom Joiner

I am writing a class like this:


Now I don't want ONE to be adjustable, I want it to be immutable, but only this one instance of the class. What is the best way to do this?

Here are some ideas..

Make an anonymous inner class, like this:


Another idea would be to put a test in the setValue like this:


What is the correct way to do this?
16 years ago
1) Does the String.valueOf(Object o) call the objects toString()? If so, why would you ever use it?

2) Why is there no valueOf(StringBuffer buffer) method when there are valueOf for many other data types which can be converted?

3) What would you use String.intern for?

Thanks for any ideas
16 years ago
I would make your class have a different name than ArrayList, perhaps MyArrayList, or ATDArrayList. It is very confusing (to a coder) to use the same class name as another class.

Then I would try stepping into your functions with your compiler and see what is happening. My guess is that you created an ArrayList and not your own class and are somehow invoking your class on a null pointer.
16 years ago
I am trying to write a regular expression to split a string on every pipe symbol (|). None of my attempts are working. Here is an example of things that fail:



Any suggestions?
16 years ago
I am trying to use sessions to keep track of when a user is logged in to the website. It is only working on pages which are redirected from the one where the session is set- it does not work if the user links to a new page.

So my first page has the following code (which has been gotten from the database successfully). It redirects to another page




This new page works, in that it can extract the friendlyName and accountID, like this



However, this same code on any other page, does not work. If you press a link to go to another page, it does not see the friendlyname.

Any ideas?
[ March 05, 2007: Message edited by: Tom Joiner ]
17 years ago
JSP
I am using Tomcat. Therefore, as I understand it, Tomcat keeps a connection pool. When I open a database connection, it is using this pool.

Now if I wanted to, I could create another connection pool- one that is owned by my application perhaps, in a servlet that keeps a set of connections. But this would be duplicating what Tomcat (I assume) already provides. Is this correct?
Then the use of a connection pool would be indicated.

This I don't quit understand. Are you suggesting we create our own connection pool, independent of the connection pool the database runs for itself?

Is this not reinventing the wheel. Wouldn't it be better coding practice to open a connection when you want it, then close it, and let the database handle having a pool?
Lets suppose I create a database connection...


Now I have an open connection. Do I need to close it explicitly?

If I do not close it explicitly, will the database run out of its pool of connections?

Thanks for any info
I am using beans successfully to store data as it passes from servlet to JSP page. Now I am hoping to send an array, of unknown size, through the bean. (The first version will be a list of products that will end up being in a table).

What is the correct way to do this?

I could do something like

<jsp:getProperty name="productTable" property="name1" /> <jsp:getProperty name="productTable" property="name2" />
<jsp:getProperty name="productTable" property="name3" />
<jsp:getProperty name="productTable" property="name4" />

But this seems absurd. Is there any way to support arrays in beans?

Looking at these links it is not clear:

http://java.sun.com/products/jsp/tags/11/syntaxref11.fm14.html

http://java.sun.com/products/jsp/tags/11/syntaxref11.fm10.html
17 years ago
JSP
I am not sure actually how to "restart the web app". I closed the browser, and then reran the application in the NetBeans IDE using "Run Main Project".

I managed to fix the problem by renaming the original servlet. Then, I added in a new link in the web.xml so that the web server could see this new servlet, and the new servlet is working properly. I am not sure what was going wrong but thanks for the ideas.
17 years ago
I am curious what the meaning is of placing jsp files down in the WEB-INF folder. I have been placing my jsp pages off of

\web\foldername\file.jsp

And now I am putting some down in the WEB-INF which will be handling responses to servlets. Is this the correct way to do it, or to lay it out in some other manner?

Thank you
17 years ago
JSP
I created the following servlet:



The problem is it always goes to "Overview.html" and never goes to Test.html. I have tried recompiling the servlet, rerunning it, and it still always goes to the place I directed it on the first compile.

Why?


Another related question.. where do people normally stick their jsp pages for handling web pages? I have been sticking them in

\project\build\web\folder\name.jsp

But now it looks like perhaps I should be placing them in

\project\WEB-INF\folder\name.jsp

which is correct?
[ November 15, 2006: Message edited by: Tom Joiner ]
17 years ago
I have been poking around the web looking for resources that talk about creating beans in Servlets, populating them, and handing them off to JSP.

Here is the best resource I have found so far:

http://courses.coreservlets.com/Course-Materials/pdf/csajsp2/14-MVC.pdf

If you come up with some more, please let me know. I find a lot about using beans on a JSP page, but very few which talk about using them from the servlet side in conjunction with the JSP side.
17 years ago
JSP
HOnestly because I thought EJB stood for "Enterprise Java Beans". Am I remiss in this understanding?

I am trying to make the leap into using beans for transferring data from Servlets to JSP pages.. and perhaps this is not the right forum for questions like that. Am I misunderstanding what EJB is?
I am hoping to get rolling with beans, and if you have any links to any simple tutorials that would be a great help.

My first bean I am hoping to access a database, get a list of names of products, and then display these on a web page.

I assume I use a servlet to populate the bean, then call a web page with a "response" bean that is set up so the JSP can read out the values. Does this sound about right?