The Concept of Making a Java Web Application and Using Database
===

I'm kinda new to java, first I started making normal java classes, then I made some programs using netbeans drag and drop, I've connected to databases and made queries on some ActionListeners, and now I decided to make a webapp, and I have some experience in HTML, CSS, JavaScript, so when I got the index.jsp file created, I made a good looking page, there's a  login form inside it, and in normal web programming, this form's action should be another PHP page, that will make server side validation, connect to database, then the user will get signed in, but for this .jsp file made in netbeans, I think we don't use PHP, only java, so I created a normal class called Login.java, this class does normal easy stuff to connect to a local database, `"select id,password from users where id="+id`, and when I tested this class it worked perfectly, but now my problem is that how should I use this class in my .jsp webapp.

I tried:

1st - the action of the form was set to action="response.jsp", so I made a new .jsp page called response, exactly like the guide made by netbeans.org, and I used beans to read the values of the input fields.

    <jsp:useBean id="loginBean" scope="session" class="test.Login" />
            <jsp:setProperty name="loginBean" property="id" />
            <jsp:setProperty name="loginBean" property="password" />

but now I had a problem with adding those values to the Login.java class, as parameters, then I got lost in how the Login class show back his returned values, and how will I get back to my first index.jsp page, and If the login is unsuccessful, I had some empty `<span id="passError"></span>` written in the index.jsp page, I want them to be like `<span id="passError">Invalid Password</span>` when the login fails, so very messy here... (I'm new to jsp and I don't know how to communicate between web pages)

2nd - I changed the value of the form to some java codes, `action="<% Login m=new Login(); m.login(); %>"` but then I had problems with adding the values, and the form will take me to the same index page, which is what I want, I want everything to remain on the same page. And other problems I went to is that I got lots of SQLException errors, those errors didn't come up when I tested the Login class, everything worked good.



