Hi. I have a JSP page and servlet and a java class. Also a .js file.
Anyways. I want to go to the database and select some variables from the database. After i select the variables i want to populate my HTML file with them with js code.

The problem is, i am able to get the data from the database and populate my HTML, but after that, if i edit the content on the html file for example a text box. i can't insert those variables to my database again. Any suggestions?

Recommended Answers

All 8 Replies

You have to use MVC approach for such purpose.
It's a common way in Java projects.
So you have to create some bean abd declare it on the page like <jsp:useBean id="myDarlingBean" class="com.darling.me.DarlingBean" scope="session"/> After that you will be able to set members of this bean to certain states and invoke certain methods from your page. The bean in turn will be invoking SELECT-INSERT-UPDATE-DELETE requests to database.

For this you have to send data from HTML to the server by sending HTTP request to server.

You can use <form> to submit data to server (.jsp file). In jsp you can do database interaction using JDBC. After that you will get resultset by executing SQL queries (SELECT...), you will create a new HTML based on the result set and send it back to client (Browser).

THis is only a flow. You need to practice some examples.

You have to write code to update database. Please follows post #2 and #3.

commented: So what was the need for you to post, if you were gonna reference the posts above u -2

i dont understand why adatapost is obsessed about increasing his solved post numbers. i cant see any other useful motivation for this behaviour of approving the previous posts.

i dont understand why adatapost is obsessed about increasing his solved post numbers. i cant see any other useful motivation for this behaviour of approving the previous posts.

If you see how adatapost's reputation goes up and down you will realize that you are not the only one who has noticed that

I appreciate your comments. I post my suggestion according to the question.

The problem is, i am able to get the data from the database and populate my HTML, but after that, if i edit the content on the html file for example a text box. i can't insert those variables to my database again. Any suggestions?

My answer was "Update database".

And now, where is your answer?

commented: wrong -1

I appreciate your comments. I post my suggestion according to the question.

My answer was "Update database".

And now, where is your answer?

we dont find it useful to repeat other people's posts. you are not even repeating, you are referring to previous post. And many times you are just adding unneccessary text to threads. we dont post anything unless we think it is useful, or contributive.
i assume that your motivation of doing this is to increase your solved threads in number, but the problem is you are losing reputation points, so it doesnt work for you. instead of replying to 5 posts concentrate on one and try to solve it stubbornly. you even replied to one of my questions by saying that you had the answer but you were going to post it two days later, and it didnt happen.

Thanks serkan,

I got the message.

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.