I am new to Servlets and JSP and am trying to write a simple web site where a user is able to register and then login. When I try to register I keep getting a stack overflow error.
Register Success JSP:
Login success jsp:
So, when I actually run my Register JSP page, fill in the form and press submit, I get the following error:
Exception in thread "http-bio-8080-exec-3" java.lang.StackOverflowError at java.util.ArrayList.<init>(Unknown Source)
I dont get any such error for my login jsp page (I am currently using dummy logic checks for the purpose of getting something up and running for the login process).
I know that a stack overflow error is caused by a call to some method or another which causes the stack to grow infinitely but as I am new to both Servlets and JSP I am unable to see where this is happening.
Your "User(n, p)" constructor at line 14 is infinitely recursive.
From a design point of view, you don't seem to know whether an instance of the User class represents a single user or a list of users.
Joined: Mar 04, 2012
Thank you for your help. I now see how it is indeed recursive.
I am actually new to this and have never programmed Servlets or JSP's before. As opposed to making a database connection (again something I have never done before) I am trying to use a Singleton User class to try and store my customer data for now.
Mohammed Uddin wrote:I am trying to use a Singleton User class to try and store my customer data for now.
You are planning to create a web site that can be used by only one person?
Joined: Mar 04, 2012
Well, I am not actually creating a website at all. This is, as one would say, a first project to see how things work.
I am using the singleton class so that I can export all data created to a csv file and I don't want more than one instance of the same class access the same file at the same time - this singleton class is there for now until I learn how to implement some form of database connectivity, storing/retrieving information from a database - the User class is just a driver/stub class.
I will be honest, I have spent no more than a total of about 5 hours across 3 days in total learning about servlets and JSP so until I get some good grounding on this I probably should not look into database connectivity. But, this said if you know of any basic tutorials for db connectivity (JDBC I think) then do let me know.