Hi ,
i have some elements in one form(sample.jsp).I want to insert that fields into database.But i know abt, the insertion of form values in to the database using next page(next page contains database connection) .But i don't know how do write the database connection within the same page(sample.jsp).

Anyone can you help me
Thank you

Recommended Answers

All 6 Replies

Hi ,
i have some elements in one form(sample.jsp).I want to insert that fields into database.But i know abt, the insertion of form values in to the database using next page(next page contains database connection) .But i don't know how do write the database connection within the same page(sample.jsp).

Anyone can you help me
Thank you

You could use Javascript to get a connection to the database. Wil that work for you?

you could also break the page into two pages.Basically, you could have the page call itself. Like if you wanted to insert username and password into your database, you could do this (this is just sample code)if (theQueryNotComplete){ Do the code for the 1st logical page. With the two elements on them.}else{ And have the info past to the database. now process info and place output.}Now in the if part, place a form/anchor that will point to the same page, this way the info is past to the current page, and it seems as if the page has gone to another, however it really stays on the same page.Even with this it may not seem as practical as above because it will still load, the other alternative is learning AJAX.

Hi ,
i have some elements in one form(sample.jsp).I want to insert that fields into database.But i know abt, the insertion of form values in to the database using next page(next page contains database connection) .But i don't know how do write the database connection within the same page(sample.jsp).

Anyone can you help me
Thank you

Please tell me how to do it in two pages.
I use JSP,PHP and mysql.
Thanks, Looking forward to your reply.'

Please tell me how to do it in two pages.
I use JSP,PHP and mysql.
Thanks, Looking forward to your reply.'

If you know JSP as you claim to know, then you would know there are servlets that are design to set connection with database and they are also able to store data in sessions. These data can be then easly retrived in JSP from session.

PS: Solution to original post is useless...

please give me the code for the same
Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.