how to capture jsf form data

how to capture jsf form data

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 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
Advertisements
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 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 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
JSF Form - Java Server Faces Questions
JSF Form  what is JSF form action
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 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 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
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
HTML Form data into .CSV?
HTML Form data into .CSV?  how to store data from html form to csvfile in java
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 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
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 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
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
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
JSF form tag
JSF form tag      This tag renders html form element which contains the data that is submitted...;head><title>jsf h:form example</title></head>  
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 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 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 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 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
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
Java Server Faces (JSF)
the JSF form validation framework.  To explore how to make your... To understand the fundamentals of the JSF framework and how it can be used... in  configuring JSF. To discover how JSF integrates with JSP
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
jsf form output - Java Server Faces Questions
jsf form output  Hi sir, see my code and please tell me mistake... have faced using this code. For more information on jsf visit to http://www.roseindia.net/jsf/ Thanks
jsf form output - Java Server Faces Questions
jsf form output  Hi sir, see my code and please tell me mistake. it is very urgent for me. here is my code: addmin.jsp... information on JSF visit to : http://www.roseindia.net/jsf/ Thanks
how to close JSF application..?
how to close JSF application..?  how to close jsf appliaction using command button with help of java code
Process HTML FORM data
Process HTML FORM data  Can a JSP page process HTML FORM data?   Yes. Preemptive termination of request processing on an error condition is a good way to maximize the throughput of a high-volume JSP engine. The trick
store form data into word document
store form data into word document  i want form page data, ex username phone number.. to store it in a word document file
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
ModuleNotFoundError: No module named 'streaming-form-data'
named 'streaming-form-data' How to remove the ModuleNotFoundError: No module named 'streaming-form-data' error? Thanks   Hi...ModuleNotFoundError: No module named 'streaming-form-data'  Hi, My
How can I POST form data from a C#/ASP.NET to a remote website?
How can I POST form data from a C#/ASP.NET to a remote website?  I'm... know how to send my data via POST to this remote PHP website. (Also note...; request.Method = "POST"; request.ContentType = string.Format("multipart/form-data
Screen Capture
Screen Capture  How to capture the screen using jsps and servlets
how to open jdialog form in jinternalframe and transfer data from jdialog to jinternalform and vice-versa - Java Beginners
how to open jdialog form in jinternalframe and transfer data from jdialog to jinternalform and vice-versa  hi....... i am developing simple application for acounts . in one form i want to use jdialog frame to search the record
multipart/form-data - JSP-Servlet
multipart/form-data  When we are uploading a file we are using the encoded type of form of type multipart/form-data. When we are using this encryption type what are will be the contents in the encoded output. Explain me
JSF Forms - Developing form based application
JSF Forms - Developing form based application   ... In this tutorial we will show you how to develop UI forms using JSF 1.2. ... will create a bean that will hold the form data (user name in this case) entered
displaying data from ms excel in form.
displaying data from ms excel in form.  Hi all, I have a requirement as mentioned below: Requirement: I have stored some data in the ms excel... (for example). I need to display these data in a form. along with the actual picture
Creating Login Page In JSF using NetBeans
illustrates you how to create a login form in JSF using NetBeans. To create the jsp page... Creating Login Page In JSF using NetBeans  ...; uri="http://java.sun.com/jsf/core" %>  <%@ 
How to create form in Swings
How to create form in Swings  How to create registration, login and question form in Java Swing?   Creating different forms in Java Swing - Examples how to create registration form in swing swing login form example
JSF
JSF  What is JSF
webpage capture
webpage capture   webpage capture source code using jsps and servlets
excel parsing and print data in the form of table
excel parsing and print data in the form of table  my reqment is i have to parse the excel and i need to print the data in the table by using swing jtable or else ....can u give the solution please
How to reset a form in jQuery?
How to reset a form in jQuery?  Hi, I have a form where I am using jQuery. I want to reset the form. How I can reset the form grammatically?   Hi, You can use following code: $("#MyFomrName").reset(); Thanks
ModuleNotFoundError: No module named 'capture'
'capture' How to remove the ModuleNotFoundError: No module named 'capture...ModuleNotFoundError: No module named 'capture'  Hi, My Python... to install padas library. You can install capture python with following command
ModuleNotFoundError: No module named 'capture'
'capture' How to remove the ModuleNotFoundError: No module named 'capture...ModuleNotFoundError: No module named 'capture'  Hi, My Python... to install padas library. You can install capture python with following command

Ads