My error from my previous post in JSP's now leads onto servlets. I was trying to figure out why i was being given the message that my data has been saved to my database, even though it hadnt. So i done some messing about with the code and found out somthing i just wish to confirm.
I have a register and login servlet, which obviously registers and logs in a user. If the user successfully logs in, then the servlet points them to here
Now in this jsp, the user has four buttons to choose, each one taking them to a new jsp. I did not however provide a servlet to this jsp in order to point the user to the new jsp. I thought i could get away with doing this
This brings up the jsp no problems, but it seems to make it no longer part of my hierachy. I am pretty sure this is my problem as i removed all the register and logn servlet and code, and i pointed my browser straight to the jsp where the user can enter a competitor (The one where no data was previously going to database). But this time it works and data is being saved. Does this make sense? So when i create a project, all linking should be done through servlets? Or can anyone think of another reason why this might of been happening?
Its difficult to explain my intention, but basically i want that jsp to load up different jsp's when a button is click. The problem i have at the moment, using the onClick command, everything loads up ok but the data never goes to the database. Its like i need a servlet to handle the actions. So if i use
Possibly removing the first line, i could then prov ide a servlet like
This way i am handling the forwarding through a servlet, and involving my Bean with it. Would this be a better approach?
If you are not submitting a form, don't use a submit button. If you are submitting a form, use the form action to specify the target, not an onclick.
In any case, forms should always be submitted to servlets, not JSPs.
Joined: Jan 03, 2009
I have tried a lot of different things, but now i am a bit stuck as to what to do. SO my user logs in, and my UserServlet handles this
So if the result is one, it brings up my CreateAtlDatabase.jsp, which is the first display page when they log in. This page has three buttons. One of them is too add a comeptitor. So i have a servlet which handles adding a competitor, which request the competitors data from the addCompetitor.jsp and sends it off to the database.
This is my problem. If i use onClick in my CreateAthDatabase.jsp, all the pages work, and everything does what it is suppossed to do, Even getting a success message back saying competitor has been entered, but nothing gets saved into the database.
If i point my browser straight to AddCompetitor.jsp, rather than the starting point off my application, everything works fine as before but the data actually gets saved to the database this time(this would tend to tell me that the problem lies in CreateAthDatabase).
If i create a new servlet for CreateAthDatabase, when i click on the Add competitor link, which should take me to the AddCompetitor.jsp, i get back the error
The requested resource (/cmt3082/servlet/servlet/DatabaseServlet) is not available.
Which looks like its searching through two Servlets. SO this is where i am confused. What can i do with this CreateAthDatabase.jsp so that it forwards to the correct page (and allows the data to be saved)