Está en la página 1de 2

8/27/13

Submit button click action to JSP without a form. (JSP forum at JavaRanch)

A friendly place for programming greenhorns!

Big Moose Saloon


Search

Java FAQ

Recent Topics

Register / Login

JavaRanch Java Forums Java JSP

Author

Submit button click action to JSP without a form.


posted 5/14/2013 9:19:59 PM

WeiJie Lim Ranch Hand Joined: Sep 05, 2012 Posts: 81

There's a remove button for each table row. When the user clicks remove, the row in which the remove button is clicked should be deleted. How do I get the onclick action to work ? =/ I tried using the 'hidden' input tag method, but I guess I messed up ..

view plain

c opy to c lipboard

print

N ote: T ext c ontent in the c ode bloc ks is automatic ally word- wrapped

0 1 . 0 2 . 0 3 . 0 4 . 0 5 . 0 6 . 0 7 . 0 8 . 0 9 . 1 0 . 1 1 . 1 2 . 1 3 . 1 4 . 1 5 . 1 6 . 1 7 . 1 8 . 1 9 . 2 0 . 2 1 . 2 2 . 2 3 . 2 4 . 2 5 . 2 6 . 2 7 . 2 8 . 2 9 . 3 0 . 3 1 . 3 2 . 3 3 . 3 4 . 3 5 . 3 6 . 3 7 . 3 8 . 3 9 . 4 0 . 4 1 . 4 2 . 4 3 . 4 4 . 4 5 . 4 6 . 4 7 . 4 8 . 4 9 . 5 0 . 5 1 . 5 2 .

< b o d y > t a b l eb o r d e r = " 1 " > < t r > < t d > T i t l e < / t d > < t d > A c t < / t d > < t d > R e l e a s eD a t e < / t d > < t d > D e s c r i p t i o n < / t d > < t d > G e n r e s < / t d > < t d > T i m eS l o t s < / t d > < t d > A c t i o n s < / t d > < / t r > < % / / R e g i s t e rJ D B Cd r i v e r C l a s s . f o r N a m e ( " c o m . m y s q l . j d b c . D r i v e r " ) ; / / D e f i n eC o n n e c t i o nU R L S t r i n gc o n n U R L=" j d b c : m y s q l : / / l o c a l h o s t / a s s i g n m e n t ? u s e r = r o o t & p a s s w o r d = r o o t l a h 2 1 3 " ; / / E s t a b l i s hc o n n e c t i o nt oU R L C o n n e c t i o nc o n n= D r i v e r M a n a g e r . g e t C o n n e c t i o n ( c o n n U R L ) ; P r e p a r e d S t a t e m e n tp s t m t ; p s t m t=c o n n . p r e p a r e S t a t e m e n t ( " S e l e c t*f r o ms h o w d b " ) ; R e s u l t S e tr s=p s t m t . e x e c u t e Q u e r y ( ) ;

w h i l e ( r s . n e x t ( ) ) { o u t . p r i n t l n ( " < t r > " ) ; o u t . p r i n t l n ( " < t d > "+r s . g e t S t r i n g ( " s h o w " )+" < / t d > " ) ; o u t . p r i n t l n ( " < t d > "+r s . g e t S t r i n g ( " A c t " )+" < / t d > " ) ; o u t . p r i n t l n ( " < t d > "+r s . g e t S t r i n g ( " R e l e a s e _ D a t e " )+" < / t d > " ) ; o u t . p r i n t l n ( " < t d > "+r s . g e t S t r i n g ( " D e s c r i p t i o n " )+" < / t d > " ) ; o u t . p r i n t l n ( " < t d > "+r s . g e t S t r i n g ( " G e n r e " )+" < / t d > " ) ; o u t . p r i n t l n ( " < t d > "+r s . g e t S t r i n g ( " T i m e _ S l o t s " )+" < / t d > " ) ; o u t . p r i n t l n ( " < t d >< i n p u tt y p e = ' h i d d e n 'n a m e = ' h i d d e n 'v a l u e = ' " + r s . g e t S t r i n g ( " m o v i e " ) + " ' >< i n p u tt y p e = ' b u t t o n 'n a m e = ' r e m o v e d 'v a l u e = ' R e m o v e ' >< i n p u tt y p e = ' E d i t ' > < / t d > " ) ; o u t . p r i n t l n ( " < / t r > " ) ; } S t r i n gg e t m o v=r e q u e s t . g e t P a r a m e t e r ( " h i d d e n " ) ; i f ( r e q u e s t . g e t P a r a m e t e r ( " h i d d e n " )! =n u l l ){ P r e p a r e d S t a t e m e n tp s t m t 2 ; p s t m t 2=c o n n . p r e p a r e S t a t e m e n t ( " D e l e t ef r o ms h o w _ d bw h e r es h o w = ? " ) ; p s t m t 2 . s e t S t r i n g ( 1 ,g e t m o v ) ; p s t m t 2 . e x e c u t e U p d a t e ( ) ; } % > < / t a b l e >

www.coderanch.com/t/611570/JSP/java/Submit-button-click-action-JSP

1/2

8/27/13
Mansukhdeep Thind Ranch Hand Joined: Jul 27, 2010 Posts: 1157
I like...

Submit button click action to JSP without a form. (JSP forum at JavaRanch)
posted 5/14/2013 10:07:43 PM

Why are you using scriptlet to perform DB access and data retrieval? Use JSPs purely to bring up the view part of your web application. Read Bear's response in

~ Mansukh

Granny's Programming Pearls "inside of every large program is a small program struggling to get out" JavaRanch.com/granny.jsp

subject: Submit button click action to JSP without a form.

Similar Threads PreparedStatement to pass user input to MySQL not working javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied "items" error? doubt regarding default values JSP and AJAX problem how do I know Edit Database Record
All times above are in your local time zone & format.T he current ranch time (not your local time) is Aug 26, 2013 14:27:32 .

Contact Us | Powered by JForum |

C opyright 1998-2013 Paul W he aton

www.coderanch.com/t/611570/JSP/java/Submit-button-click-action-JSP

2/2

También podría gustarte