aspose file tools
The moose likes JSP and the fly likes passing a variable to a Bean's method Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSP
Reply Bookmark "passing a variable to a Bean Watch "passing a variable to a Bean New topic
Author

passing a variable to a Bean's method

Charessa Reilly
Ranch Hand

Joined: May 26, 2011
Posts: 39
I have these two methods in a Bean:





of I call the first method from inside eclipse, it writes a new record in the database and all is well.

If I try to call the method from inside a jsp file, thusly:


I get no errors, but the connection to the database never closes and the new record never gets written.

I feel so newb about this. I keep asking questions that probably make me look foolish.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56554
    
  14

You're mixing JSTL and scriptlets?


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Charessa Reilly
Ranch Hand

Joined: May 26, 2011
Posts: 39
so.. I take it that's a no no?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56554
    
  14

Yes. JSTL and EL are meant to replace scriptlets and they are not designed to work together. Choose either to use discredited scriptlets or JSTL/EL, but not both. That's just a big ol' mess.
Charessa Reilly
Ranch Hand

Joined: May 26, 2011
Posts: 39
aight.

So my understanding then is my other real option is to make a custom tag?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56554
    
  14

That's one of many approaches. There are also custom EL functions, and other means. Which to choose depends upon the scenario.

But the first thing to always do is to ponder whether it's something that should have been handled in the controller rather than waiting until you get to the JSP.
 
 
subject: passing a variable to a Bean's method
 
Similar Threads
DATABASE OBJECT-- URGENT URGENT
Bean not working with JSP
inserting values from a class to a mysql database
Data Access Code
Java Bean not functioning as expected.