I'm tempted to post this on the beginner's forum, but because it is specifically regarding JSP and JSTL, I'll put it here, with apologies that it's a much more simple question than you might want to see here.
I am trying to do something relatively simple: Have a user input a string on a form, and then have that string passed to a .jsp page. For some reason, which I'm guessing is probably something very, very basic that I'm missing, the parameter isn't getting passed.
Here's the form (add_form.html):
and here's the jsp page (adddoc.jsp):
So--the combination of these two neither updates the database nor prints out the input string from the form on the page.
If I create a form which includes the adddoc.jsp stuff within itself, then once I fill out the form and click 'submit', everything goes as planned--the database gets updated, and the value of the input gets printed out to the screen (adddocform.jsp):
So, I'm thinking that I'm not doing something that needs to be done to get the parameter to get passed from the form to the .jsp.
Any ideas? I'm using a great book, "JSTL in Action," but according to the book--as far as I can tell--my code should work. So.
With regards to determining whether it's the form submission that's the problem or not, simplify. Remove the SQL stuff from the page and make sure that the value of "d" is making it through.
As a beginner, I'd be remiss if I did not point out that performin SQL operations on a JSP page is generally severly frowned upon as a heinous violation of the principle of "separation of concerns". I'd advise getting off on the right track early on and factoring your business logic out of the pages and into Java classes. [ March 16, 2006: Message edited by: Bear Bibeault ]
JSTL version 1.1(2.0) and Tomcat 5.0 are what I'm using, if that helps.
I also appreciate the heads up on keeping business logic out of jsp pages. I'm doing this as a learning exercise for myself--in fact the applications that I deal with only use jsp pages to do simple select statements from simple databases for reports on what's in the database and such, and I'm just trying to expand my knowledge using them as starting points. I also understand that even select statements in jsp pages are frowned upon.
I took your advice and took out the sql stuff and tried to run things without the sql stuff, and the param was passed just fine. I then reinserted the sql stuff and IT works now too. So, I'm sort of back to square one (except that it now works!) and recognizing that I must have been doing something wrong in the implemetation of the code (along the lines of Tomcat not using the version of the .jsp that I thought it was, but not that, since I think I've checked and double checked all of that).
At any rate, thanks for your help!
(Was this an ok question for the jsp forum, or did it belong in the beginner forum?)