File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes jsp problems, only one part of code executes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp problems, only one part of code executes" Watch "jsp problems, only one part of code executes" New topic

jsp problems, only one part of code executes

Rogelio Trist�n

Joined: May 12, 2005
Posts: 4

okay the code is supposed to make a table and display student names from the student table, and then afterwards have some text boxes to enter the student name you want to edit, then the new student info (new name and new id number)... well when I execute it, it will show a form for asking wwhat data to update, but it completely skips the first part of the code that sets a table to display the list of students...... funny thing is, when I delete the part about asking for student update info, it will show the list of students... why will it only do the second part of the code when I have them both? how do I make it both show all students in the database, AND ask for student info to update at the bottom ?
thanks guys I appreciat it
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Rogelio Trist�n,
Whenever you post more than a line or two of code, you should wrap them in the UBB Code tags (there is a button to generate them on the reply screen). These tags will preserve your code's indenting -- making it easier for others to read. This, of course, makes it more likely that someone will actually read it and thus, makes it more likely that you will get help.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Rogelio Tristan

Joined: Nov 16, 2004
Posts: 4
what do you mean? I did put it in CODE tags...

anyone know the answer?
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

what do you mean? I did put it in CODE tags...

You did.
I see them there now.
Not sure how I missed them.
I apologize.. profusely

There are a lot of little things that could be giving you trouble
Such as improper xml syntax:

and submit tags that are not within the HTML form tags:

Also, within your form, I don't see any input fields at all so I'm not sure how they could be showing:

and within that form there is a table without any TD or TR tags.

There may be another small syntax error that is preventing your table from rendering. Try looking at the HTML source to see if it is being printed to the page but not rendered due to an HTML bug.

The above points are, for the most part, nitpicking.
There is one very serious problem with this code that I want to point out:

Whenever you declare variables like this:

you're creating what are called instance variables.
Variables declared this way are not thread-safe.
They are shared by all requests being processed by your JSP and will lead to major concurrency issues if not fixed.
Unless you have a pressing need to do this and know exactly what you're doing, you should avoid it.
Declare all of your variables inside the JSPs service method by not using the <%! operator.
[ May 14, 2005: Message edited by: Ben Souther ]
I agree. Here's the link:
subject: jsp problems, only one part of code executes
It's not a secret anymore!