Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSF-Questions how to capture jsf form data
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


srikala
how to capture jsf form data
1 Answer(s)      6 years and 3 months ago
Posted in : Java Server Faces Questions



Advertisement
View Answers

October 17, 2008 at 5:23 PM


Hi friend,

"user.jsp"

<%@ page contentType="text/html"%>
<%@ taglib uri="http://java.sun.com/jsf/core"; prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html"; prefix="h"%>

<f:view>
<html>
<head><title>JSF Simple Login Example</title></head>

<body>
<h:form>
<table>
<tr>
<td><h:outputText value="Enter Login ID: " /></td>
<td><h:inputText id="loginname" value="#{SimpleUser.loginname}" /></td>
</tr>
<tr>
<td><h:outputText value="Enter Password: " /></td>
<td><h:inputSecret id="password" value="#{SimpleUser.password}" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><h:commandButton value="Login" action="#{SimpleUser.addUser}" /></td>
</tr>
</table>
</h:form>
</body>
</html>
</f:view>

"faces-config.xml"


<managed-bean>
<managed-bean-name>SimpleUser</managed-bean-name>
<managed-bean-class>roseindia.SimpleUser</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>


<navigation-rule>
<from-view-id>/pages/user.jsp</from-view-id>
<navigation-case>
<from-action>#{SimpleUser.addUser}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/pages/resultforsuccess.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-action>#{SimpleUser.addUser}</from-action>
<from-outcome>fail</from-outcome>
<to-view-id>/pages/resultforfail.jsp</to-view-id>
</navigation-case>
</navigation-rule>


"SimpleUser.java"


package roseindia;
import java.sql.*;

public class SimpleUser{
String loginname;
String password;
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";;
String dbName = "user_register";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String db_password = "root";

public SimpleUser(){}

public String getLoginname(){
return loginname;
}

public void setLoginname(String loginname){
this.loginname = loginname;
}

public String getPassword(){
return password;
}

public void setPassword(String password){
this.password = password;
}

String query = "" ;
public String addUser(){

Statement stmt;
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,userName,db_password);
System.out.println("Connected to the database");

query = "insert into userregister set username='"+loginname+"', password='"+password+"'";

stmt = conn.createStatement();

int i = stmt.executeUpdate(query);
if(i>0)
{
return "success";
}
conn.close();
System.out.println("Disconnected from database");
} catch (Exception e) {
e.printStackTrace();
}
return "fail";
}
}

For more information,Tutorials and Examples on JSF visit to :

http://www.roseindia.net/jsf/

Thanks


Related Tutorials/Questions & Answers:
how to capture jsf form data - Java Server Faces Questions
how to capture jsf form data  hi , i have a jsf page with username ,password and submitt button,if i submitt the data then it has to store in the database this is the task i have to do plese tell me the procedure how to do
How to capture screenshot in url?
How to capture screenshot in url?  Hi, How to capture screenshot and it will store the capture image in url like this http://localhost/xxx/yyy/ it wil not sore C:\ or D:\ it should store like this http://localhost/xxx/yyy
Advertisements
capture
capture  How can i capture values or text selected in drop down menu or in combo box or in any input forms and print it on the same page ?? also the selected value i want to store it in data base. how can i do that?? plzzzz
how to featch data form db?
how to featch data form db?  how to featch data form db?   ...(){ $.getJSON('get','act=all',function(data){ var...="thumbnail">' +'<img data-src="holder.js/300x200
How can we save a data list in jsf?
How can we save a data list in jsf?  I have a code in jsf that fires a query in Data Base each time it is called, i have added a validation check to fire query only if list is not-empty but the list gets empty each time
Data Capture from resume - JSP-Servlet
Data Capture from resume  Hi Sir, In My Application, when i Upload a resume the relevant columns like name,phone,email,skills etc need to be captured automatically and must be stored into the database. Please solve
how to post data in mysql php form
how to post data in mysql php form  how to post data in mysql php form
How to capture video and then how to store it in mobile memory
How to capture video and then how to store it in mobile memory  Hello there, I'm developing a mobile application where i'm capturing video from... but they are not working properly some of them capture video but doesn't allow me
How to capture output from console into textarea in java?
How to capture output from console into textarea in java?  Hi, I would like to know how can we display the result of a program in java into a textarea instead of displaying it on console. Thanks
How to capture picture from webcam using java
How to capture picture from webcam using java  i want catch the image from web-cam using jsp, If anyone knows please answer me
how to display database data in jsf page - Java Server Faces Questions
how to display database data in jsf page  Hi, i created tables in database,now i need to display the tables in jsf page.Means i have to get...://www.roseindia.net/jsf/dataTable.shtml 2.Do some changes in "TableBean.java" class
how to get the data from database&how to display the database data in jsf - Java Server Faces Questions
how to get the data from database&how to display the database data in jsf ... data in jsf. plese tell me the solution with example. Thanks in advance. ... and to display the data from database in jsf visit to : http://www.roseindia.net/jsf
How to upload image to server in j2me by multipart/form-data?
How to upload image to server in j2me by multipart/form-data?  Hi, I need upload data to java server from j2me 1.Two text messages and 3 capture... in multi part form data. 3.As write code to upload text and image.As it is working
JSF Form - Java Server Faces Questions
JSF Form  what is JSF form action
How to display data in form using aryylist in struts - Java Beginners
How to display data in form using aryylist in struts  Hi, I want to display data using arraylist in struts pls help me Its urgent
How to use enctype="multipart/form-data" in DOJO - JSP-Servlet
How to use enctype="multipart/form-data" in DOJO  Hi All, I am... form method = "post" & enctype="multipart/form-data". In same page I am using... for enctype="multipart/form-data". Then I delete that tag & then try to upload
how to make drop down list in JSF & fetch data Item from database
how to make drop down list in JSF & fetch data Item from database  how to make drop down list in JSF & fetch data Item from database
How to save form data to a csv file using jquery or ajax
How to save form data to a csv file using jquery or ajax  Please let me know more about how to do this or please suggest me any sites to learn...=data.responseText; Now the problem is ,i should write form data to a csv file using ajax
Screen Capture
Screen Capture  How to capture the screen using jsps and servlets
HTML Form data into .CSV?
HTML Form data into .CSV?  how to store data from html form to csvfile in java
how to get a values from a multipart/form-data - JSP-Servlet
how to get a values from a multipart/form-data  Dear sir , I... submitForm(f){ var form = document.createElement("form"); with(form) { method = "post"; action = "newEntryDetails2.jsp"; name = "form"; id = "form
How to insert data into databse by JSP form registration page in netbeans
How to insert data into databse by JSP form registration page in netbeans  .... & how to connect tht form to my databse , so it can store data?   1...; password, & after submitting this form it automatically stores data
how to save html form data into .csv file using only jsp.
how to save html form data into .csv file using only jsp.  Dear all, I am developing a website only using jsp and html. i need to save the form data... inserted into the excel file. 1)Create form.jsp <html> <body> <form
How do i validate form using javascript and send data to database?
How do i validate form using javascript and send data to database?  I need a "JOIN US" form that can validate using javascript and be able to connect with and post data into a database. The details to be validated and posted
JSF Form Validation
about JSF. In this section on "JSF Form Validation" you will learn how to validate the JSF Form using tag libraries provided along with JSF 1.2...JSF Form Validation         
How to use dojoscript with jsf?
How to use dojoscript with jsf?  Hi all , am new to jsf. can anyone help me out in using dojo script frame work with jsf. how to integrate dojo into jsf. Thanks in advance
how to close JSF application..?
how to close JSF application..?  how to close jsf appliaction using command button with help of java code
validating a form before data is entered.
validating a form before data is entered.  How can I avoid validating a form before data is entered
webpage capture
webpage capture   webpage capture source code using jsps and servlets
Display Data from Database in JSF Application
Display Data from Database in JSF Application  ... data from database in JSF application. Developing JSF  Application In this section, we are going to display data from database in JSF based web
How create csv format in jsf ?
How create csv format in jsf ?  Dear Friends , Good morning to all of you? I have a problem to create .CSV format in jsf. Actully I have successfully created .PDF files of my jasper report form jrxml in jsf
Advertisements
 

 

 

DMCA.com