Results 1 to 4 of 4
  1. #1
    FamilyGuy is offline Member
    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

    Default Create registration form | insert into database | call the database

    form.jsp

    XML Code:
    <form action="requestobject.jsp" method="post">
    	Nim <input type="text" name="txtNim"/>
        Nama <input type="text" name="txtNama" />
        Jenis Kelamin <select name="txtJenisKelamin"> 
        			  	<option>Laki-Laki</option>
                        <option>Perempuan</option>
                      </select>
        Alamat <textarea name="txtAlamat" cols="20" rows="10"></textarea>
        Telp <input type="text" name="txtTelp" />
        Status <select name="txtStatus"> 
        			  	<option>Separated</option>
                        <option>In Relationship</option>
                      </select><br />
        Hobi <input type="text" name="txtHobi" />
        <input type="submit" value="Submit" name="txtSubmit" class="submit" />
        
    </form>
    here is my JSP
    Java Code:
    <%@page import="java.util.*" %>
    <%
    	String Nim, Nama, JenisKelamin, Alamat, Telp, Status, Hobi;
    	if(request.getParameter("txtNim") == null)
    			Nim = "";
    	else
    			Nim = request.getParameter("txtNim");
    			
    	if(request.getParameter("txtNama") == null)
    			Nama = "";
    	else
    			Nama = request.getParameter("txtNama");
    			
    	if(request.getParameter("txtJenisKelamin") == null)
    			JenisKelamin = "";
    	else
    			JenisKelamin = request.getParameter("txtJenisKelamin");
    			
    	if(request.getParameter("txtAlamat") == null)
    			Alamat = "";
    	else
    			Alamat = request.getParameter("txtAlamat");
    	
    	if(request.getParameter("txtTelp") == null)
    			Telp = "";
    	else
    			Telp = request.getParameter("txtTelp");
    			
    	if(request.getParameter("txtStatus") == null)
    			Status = "";
    	else
    			Status = request.getParameter("txtStatus");
    	
    	if(request.getParameter("txtHobi") == null)
    			Hobi = "";
    	else
    			Hobi = request.getParameter("txtHobi");
    
    %>
    
    
    <form>
    	Nim <%=Nim %><br />
        Nama <%=Nama %><br />
        Jenis Kelamin <%=JenisKelamin %><br />
        Alamat <%=Alamat %><br />
        Telp <%=Telp %><br />
        Status <%=Status %><br />
        Hobi <%=Hobi %>
        
    </form>
    How to store all this input into sql database?
    i already installed jasperreport, but i dunno how to create a database. Before i get in touch with jsp, i just use phpmyadmin from XAMPP
    now i use different server, i dunno how to do that, can anyone lead me?

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: Create registration form | insert into database | call the database


  3. #3
    FamilyGuy is offline Member
    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

    Default Re: Create registration form | insert into database | call the database

    @doWhile : btw, what IDE i should use to create that database? and where should i put it? i found many code, i just dunno where to place it

    Example, if in XAMPP (phpmyadmin), i just go to http://localhost/phpmyadmin/ then create a database over there, if i use jasperserver, where i can do something like that to create database? or i should use IDE to create that? i am confuse because every tutorial doesn't show how to create from the beginning (for dumb beginning xD ), they just start with the code

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default Re: Create registration form | insert into database | call the database

    I would suggest learning about whatever database you are planning on using first.
    Almost all of them come with some from of front end to use, even if it's just a command line based thing.
    That way you'll know how your database works, which is pretty important if you plan on using them.

    Then create a simple Java app that connects to the database and runs some SQL (SELECT, INSERT, UPDATE, DELETE) just so you have some idea of how all those things work.
    That will give you a basic toolkit of code that you can then apply to your problem above.

    Note, I would not do this in a JSP but in a Servlet, indeed in some separate code that the Servlet calls. That's a lot easier to debug than JSP code, which should be just for displaying the results.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. insert vector to database
    By jperson in forum JDBC
    Replies: 4
    Last Post: 01-20-2011, 02:42 AM
  2. how to insert data in database
    By Vinay Bhatia in forum JDBC
    Replies: 6
    Last Post: 11-03-2010, 04:06 PM
  3. why i can't insert data to database
    By khaa_khay in forum Web Frameworks
    Replies: 0
    Last Post: 05-26-2010, 05:37 AM
  4. Replies: 3
    Last Post: 02-28-2009, 09:17 AM
  5. Probeleme with insert into database oracle
    By bachtoutou in forum New To Java
    Replies: 0
    Last Post: 05-24-2008, 11:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •