Any tutorials on creating a simple Login using Mysql and sessions?

Hey guys. I cannot seem to find any information(online) or books that cover sessions in JSF and how to do a simple log in. I can get the application to query a mysql table and check the credentials and go to the next page, but I'm not sure how to make that page locked from non authorized access. I am very familiar with PHP and using it to create database driven applications. It's very straightforward, making safe logins using mysql, and creating sessions once the user has logged in(making pages locked unless the user is logged in, etc).. I have the core java server faces book but it's a joke. I feel like its an incomplete book. It merely skims a topic, and when you think it's going to get interesting it moves on to something else. It teaches basic stuff but nothing of what I want to do(or need to do). The older Javaserver faces book that came out in 2004 from O'Reilly doesn't seem to help either. I'm just wondering where people learn JSF at. I know Java, I would say pretty well as far as desktop applications go. I really like the way JSF is layed out and would really like to use it in my next project. At the level I know it now it's perfect for static web pages with no dynamic information.(but I could use plain html for that). Thanks for all your help.

dothedru22 wrote:
but I'm not sure how to make that page locked from non authorized access.You can use a Filter for that. Map the filter on the desired url-pattern and write doFilter() logic which checks if the user is logged in (basically: if there is an User object in the HttpSession) and handle accordingly (chain.doFilter() on success or response.sendRedirect on fail).
and creating sessions once the user has logged in(making pages locked unless the user is logged in, etc).. The HttpSession is backed by a cookie (as is PHP's $_SESSION, did you know that?), you don't need to do any low-level stuff with cookies. Maybe at highest if you ever want a "remember me on this computer" option.
booksThe mentioned books learns you the JSF basics. They doesn't really learn the best practices / practical use cases. There you have other resources for (or just practical experiences). Besides, I recommend you to go get a book which covers JSF 1.2 or newer. The mentioned ones are outdated, as is everything else older dan two years in the programming world.

Similar Messages

  • I am new on flex, and i would like to create a simple login + password using amfphp

    Hi all,
    I try to make a simple login password using mysql and amfphp, i have a little quesiton, i dont' know how to get back my response from php. Thanks in advance if anyone could help me.
    Best regards
    i would like to tell to the label    <mx:Label x="380" y="10" id="lResponse"/> the response from php
    I juste want to take back response from php.
    Here is my mxml :
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768">
        <fx:Script>
            <![CDATA[
                import mx.controls.dataGridClasses.DataGridColumn;
                import flash.net.Responder;
                import mx.events.DataGridEvent;
                import org.corlan.VOAuthor;
                private function checkpassword():void {
                    var newauthor:VOAuthor=new VOAuthor();
                    newauthor.lname_aut = nom.text;
                    newauthor.fname_aut = prenom.text;
                    myRemote.validate(newauthor);
                private function checkInput():void
                    if(nom.text == "" || prenom.text == "")
                        lResponse.text = "Veuillez completer tout les champs";
                    else
                        lResponse.text = "connecter";
                        checkpassword();
                    //    checkLogin("login.Verify.validate",[nom.text,prenom.text]);
            ]]>
        </fx:Script>
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
            <mx:RemoteObject id="myRemote" destination="MyService" source="MyService"
                             endpoint="http://localhost/amfphp/gateway.php" showBusyCursor="true"/>
            </fx:Declarations>
        <s:Panel x="334" y="168" width="245" height="135" title="Identifiez vous" textAlign="center">
            <s:TextInput x="102" y="10" textAlign="left" id="nom" />
            <s:TextInput x="102" y="40" textAlign="left" id="prenom" />
            <s:RichText x="50" y="6" text="Login :" height="22" width="56" textAlign="left" verticalAlign="bottom"/>
            <s:RichText x="27" y="46" text="Password :" height="20"/>
            <s:Button x="125" y="70" label="Connecter" width="105" click="checkInput()"/>
            <mx:Label x="380" y="10" id="lResponse"/>
        </s:Panel>
    </s:Application>
    Here is my php code :
    <?php
    session_start();
    require_once ('./vo/org/corlan/VOAuthor.php');
    //conection info
    define( "DATABASE_SERVER", "127.0.0.1");
    define( "DATABASE_USERNAME", "root");
    define( "DATABASE_PASSWORD", "xxxx");
    define( "DATABASE_NAME", "flex360");
    class MyService {
        function validate($author){
            $mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD);
            mysql_select_db(DATABASE_NAME);
            $user = $author[0];
            $pass = $author[1];
            $query = "SELECT DISTINCT * FROM authors_aut WHERE fname_aut = '$user' AND lname_aut = '$pass'";
            $rs = mysql_query($query);
            $var = mysql_fetch_assoc($rs);
            $u = $var["fname_aut"];
            $p = $var["lname_aut"];
            if ($pass != $p){
                $response[0] = "INVALID";
                $response[1] = "Invalid username and/or password";
            } else {
                $response[0] = "VALID";
                $response[1] = "Welcome $u";
            return $response;
    ?>

    I usually have a resultHandler function, to handle stuff from the server.
    resultHandler(event:ResultEvent):void

  • How to create a simple app using the MVC approach?

    Hello gurus i'm trying to learn the SAPUI5 and i'm trying to create a simple app using the MVC i created the app and trying to add a lable to the view but there is nothing appear when i run it the code for the HTML page
    <!DOCTYPE HTML>
    <html>
      <head>
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
      <script src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
      id="sap-ui-bootstrap"
      data-sap-ui-libs="sap.m"
      data-sap-ui-theme="sap_bluecrystal">
      </script>
      <!-- only load the mobile lib "sap.m" and the "sap_mvi" theme -->
      <script>
      sap.ui.localResources("mytestapp");
      var view = sap.ui.view({id:"idshell1", viewName:"mytestapp.shell", type:sap.ui.core.mvc.ViewType.JS});
      view.placeAt("content");
      </script>
      </head>
      <body class="sapUiBody" role="application">
      <div id="content"></div>
      </body>
    </html>
    the code for the view
    sap.ui.jsview("mytestapp.shell", {
      /** Specifies the Controller belonging to this View.
      * In the case that it is not implemented, or that "null" is returned, this View does not have a Controller.
      * @memberOf mytestapp.shell
      getControllerName : function() {
      return "mytestapp.shell";
      /** Is initially called once after the Controller has been instantiated. It is the place where the UI is constructed.
      * Since the Controller is given to this method, its event handlers can be attached right away.
      * @memberOf mytestapp.shell
      createContent : function(oController) {
      var oLabel = new sap.ui.commons.Label("l1");
      oLabel.setText("Test label");
      oLabel.placeAt("content");
    i dont know what is wrong or if i should use a container to display my controls
    any help will be appreciated
    thanks in advance

    Hi,
    Instead of   oLabel.placeAt("content"); use return oLabel;
    so it will as below,
    createContent : function(oController) {
      var oLabel = new sap.ui.commons.Label("l1");
      oLabel.setText("Test label");
      return oLable;
    Regards,
    Chandra

  • How to create a dynamic newsflash using dreamweaver and PHP

    Hi there,
       I would like to create a dynamic newsflash using dreamweaver and PHP in that the newsflash will be pulling information from a MySQL database. The newsflash should also have a link to view more information about the piece of news a user wants to know more about. Which tools do I need to use in dreamweaver and how's the procedure to go about that. Any advice is highly appreciated. Thanx in advance!

    I think you´ll need at least a MySQL table with the following columns:
    - id (primary key, int, auto_increment etc)
    - news_headline (varchar)
    - news_teaser (text)
    - news_content (text)
    What I´d personally add are columns such as:
    - news_date (date or datetime)
    - news_external_link (varchar), if a "read more..." link is supposed to navigate to an external URL rather than displaying the contens of the "news_contents" column.
    Based on such a MySQL table it should be easy to use Dreamweavers standard Server Behaviors to create the usual datalist.php, insert.php, update.php and delete.php documents, and there are numerous tutorials out there which will teach you how to do that.
    Am I right when assuming that you´ll also need to know how to automatically pull, say, the 5 most recent news records from the database ?

  • Developer-Online New Tutorial Released: Create a Flickr gallery using jquery and JSON

    Create a Flickr gallery using jquery and JSON
    Hello everyone, In this tutorial I'll show how is simple to build your Flickr photo gallery using jQuery framework and JSON. We'll see how to setup thumbnail's numbers, convert your RSS Flickr in a JOSOn format and display theme. Thank You for your attention!
    Posted on:                                       2010-01-11 10:20:48
    Author: patrizio Quatrini
    Best Regards
    Waleed Barakat

    Heya,
    When I first read your post I originally thought you were posting a tutorial about whether a chosen username has already been resigtered or not on the signup page like this tutorial:
    http://DwFAQ.info/signup_demo.php
    Spry Check Username Availability
    Date Created: Sunday, July 5, 2009 2:29 PM
    Then after looking at the page you've linked to and trying to understand the objective of the tutorial I've noticed that you are talking about something like this:
    http://DwFAQ.info/home.php?id=7
    Spry Search
    Date Created: Sunday, March 1, 2009 8:51 PM
    It's pretty simple to do with the link I've referenced. Simply create your database with populated tables, use the mentioned script to convert the database data into xml syntax, then enter your dynamic database script as the location of the xmlDataSet in the spry page linked.
    View source on this page which shows the non-destructive filter in action to see how it's done! You can also spice it up a little for products, etc. by using this method. The key is to create a dynamic xml syntax from your database and then use the dynamic xml script location as your xmlDataSet in the search page.
    I have an example of the auto suggest search on my homepage http://DwFAQ.info
    On the top-left side of the page click on the link that says Search Tutorials to reveal the search form. Then start typing characters into the search box to see the entries instantly filter according to the characters that are typed. You can also filter further by clicking on the category checkboxes to filter by keywords AND category.
    You can view the source code on my homepage to see the location of the dynamic xml syntax referenced as the xmlDataSet location and how it was implemented into the site.

  • Is there any way to create an installer for Mac OS and Linux OS once a stand alone application is created?

    Is there any way to create an installer for Mac OS and Linux OS once a stand alone application is created?  I have created an executable application that I want to distribute to Mac and Linux users (different applications were created in the respective OS).  I was wondering if there is any way to create an installer?  I think there probably isn't...  If the user were to simply download the Labview Run-time Engine from ni.com would they be able to run the application or is it more complicated than that?
    Thanks so much for your time.

    I think Shane tried to say, that it is on the Mac OS X installation DVD, NOT the LabVIEW for Mac OS X installation medium. And that could very well have changed in recent Mac OS X versions as well. They used to have Xcode on it too, but that seems gone as well.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Creating a simple java client for a session EJB local interface

    Hi all
    Is it possible to create a simple java client for a session ejb local interface with JDeveloper.
    The problem is that it creates a test client for a remote interface only...
    i.e.
    MySessionEJB sessionEJB = context.lookup("MySessionEJB")
    and once i try to adjust it manually for the local interface...
    MySessionEJBLocal sessionEJB = (MySessionEJBLocal) context.lookup("MySessionEJBLocal") (MySessionEJBLocal - is the name of my local interface)
    it generates the exception:
    javax.naming.NotFoundException: SessionEJBLocal not found
    at...........................(RMIClientContext.java:52)
    There is still no problem with accessing the local interface object from the jsf project where i've added <ejb-local-ref> tag into the web.xml file.
    but i need the possibility of testing the simple java client for the local interface to test business methods wich should return objects without indirect properties
    Thanks in advance.
    Alex.

    Pedja thanks for reply.
    I still dont understand what is wrong with my example.
    The first peace of the code i wrote (getting the reference to the remote interface object) works pretty well, and even more it is produced automatically by JDeveloper, so why we cant get a reference to the local interface object the same way?
    Certanly we should use the local interface for getting access to the resource functioning under the same local jvm and i think it doesnt metter wich app server we really use wls or oas or others
    Thanks. Alex.

  • I have created an iPhone app using xCode and am now ready to publish it. Do I have to sign up to the $99/yr program in order to get a certificate?

    I have created an iPhone app using xCode and am now ready to publish it. Do I have to sign up to the $99/yr program in order to get a certificate? I keep getting the error message: CodeSign Error: code signing is required...although the app tests fine on the simulator. Does this mean that I need to pay the $99 to create the app or do you only need to pay if you want it published on iTunes?
    Any advice will be gratefully received.

    App Store Resource Center - Apple Developer

  • I need to know how I will create a dynamic website using php and mysql

    I need to know how will I create a dynamic website using php and mysql that people could have the abilities of registering in the website, and modify their profile where they can add their pictures and everything. apart from that, they should have the ability to search about other member. hope to here more from you.

    If you are a right-brained creative, and have no previous experience or propensity to be able to understand coding and database "stuff", and/or if your time can be better spent on other skills, I recommend you save your sanity and hire a developer... or at least the first time around. I have been attempting to grasp this for years... and have a library of marked up books to prove my efforts, all while trying to keep up with an ongoing client base that is always cramped. It's a wonder I still have my sanity... then again, I might not be the best person to determine that. Others might question it.
    That said, I still plan to master php... one of these days.

  • Is Adobe Connect part of Adobe Creative Cloud? Are there any best practices ideas from people who use Connect and Creative Cloud?

    Is Adobe Connect part of Adobe Creative Cloud? Are there any best practices ideas from people who use Connect and Creative Cloud?
    I have an Adobe Connect account and I'm are also in the early stages of developing a webinar. I am looking for any tips and advice from anyone who uses both of these services.

    As the £27, was an introductory offer. Upon the completion of one year, the price will change to the normal creative cloud cost which is at £46.88. However if you have the previous versions of the creative suites like CS 3, 4, 5, 5.5 or the CS 6. You can avail the offer at £27.34 per month incl. VAT. However this Requires annual commitment; billed monthly.

  • How to create ssas cube by using MySQL Database

    please tell me step by step process to create ssas cube by using MySQL database in my system, i have Sqlserver 2008 enterprise edition and MySql5.0

    There is an OLEDB provider for MySQL which you can get from here
    https://cherrycitysoftware.com/ccs/Providers/ProvMySQL.aspx otherwise you can also use SSIS to push the data straight into the Analysis Services database without needing to stage it in SQL Server. Also, as you can load data into AS using XMLA you could
    also write your own loader to extract data using ODBC and push it into AS using XMLA, essentially what I suspect SSIS does. However those latter solutions don't allow you to create a database on top of MySQL because you need an OLEDB (or .net) provider for
    that.
    In the simplest case, install the OLEDB provider and then in AS create a Data Source connection using that provider. Once you have done that you should be able to create a Data Source View using that connection enabling you to import the schema definitions
    for the tables/views in the MySQL database. From there you build dimensions and cubes etc. about which there is plenty of information on the web.
    http://bi-logger.blogspot.com/

  • Creating a simple Login screen

    Hi folks,
    I'm a beginner trying to develop some code for a simple login screen for a database.
    I know that some packages (Access) have tailor-made code for this but can't seem to find
    anything in Oracle to do this. Can anyone help or point me in the right direction ?
    I'm using Oracle 8i and Forms 6i(8.1.7) running on Windows NT4.
    Thanks in advance,
    John

    Forms has a default for that.
    When you start a form with Forms runtime, the login screen is displayed automatically.

  • Need help on how to create the simple mapping using ORACLE DATA INTEGRATOR

    Hi guys,
    am new to learn odi.. please share me or steps how to develop the simple mapping using ODI...

    Hi,
    I am a newbie to Oracle Data Integrator as well. You should have a look here first; http://www.business-intelligence-quotient.com/?p=379
    Try to play around with ODI and then come back if you have specific questions. You should better move to this ODI-forum; Data Integrator
    Good Luck,
    Daan Bakboord
    http://obibb.wordpress.com

  • Login using j_security_check and redirect to a jspx.

    I have a login.html file and created a form with two input fields for username and password. When I submit the form using a button, it posts 'j_security_check'.
    After successfull login it takes me to welcome page defined in web.xml. I have specified index.html file as welcome page and added a redirect on index.html to get redirected to adf faces page.
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"></meta>
    <meta http-equiv="refresh"
    content="0;url=./faces/Dashboard" />
    <title>Portal Home</title>
    </head>
    <body></body>
    </html>
    Its workig fine but now we want to have two dashboards and user should get redirected to one of them depending on his role. For example if user has 'HR' role he should be redirected to HRDashBoard and if he has manager role he should be redirected to ManagerDashboard.jspx.
    I tried using bean call from html but I think its not possible. How to do it?

    Our usecase is slightly different.
    We have login.html and not login.jspx, which we can put on adfc-config.xml file. login.html is provided by some other team so we can not create our own jspx.
    I have put router thing in adfc-config.xml but problem is 'How to call router activity from index.html' file. In index.html I can point url to any view-activity of adfc-config but I can't point it to a router activity of adfc-config.
    Now the problem is 'From index.html, redirect in such a way so that unbounded flow adfc-config.xml starts from a router activity.'
    Thanks
    Sanjeev

  • Creating short photo gallery using previous and next frame A3.0

    I'm creating a simple photo gallery.
    Can someone tell me the right code this is what I'm remember. I forgot.
    next_btn.addEventListener(MouseEvent.CLICK, goNext);
    previous_btn.addEventListener(MouseEvent.CLICK, goBack);
    function goNext(e:MouseEvent):void {
    gotoAndStop("nextFrame");
    function goBack(e:MouseEvent):void {
    gotoAndStop("previoudFrame");
    I know it's wrong can someone help me out?
    Thanks

    inside your functions use just
    nextFrame();
    and
    prevFrame();
    and get rid of those gotoAndStop and it should work...

Maybe you are looking for

  • Can anyone tell which i7 quad core processor Macbook pro 15 inches has? i7-4800MQ or i7-4900HQ?

    Can anyone tell which i7 quad core processor Macbook pro 15 inches has? i7-4800MQ or i7-4900HQ? Thanks Mahi

  • Wanting to buy Iphone

    To Whom It May Concern, I want to buy a phone/pda that is for my business activities...is Iphone's To Do List and Calender function really good? easy to use? can anyone share your experience with me...so I can really make sure I can buy Iphone

  • Trigger on FND_USER_RESP_GROUPS_DIRECT

    Hi All, I want set audit for Users' responsibilities so i want to write event altert on "FND_USER_RESP_GROUPS_DIRECT". But i am not able to find table name. kindly suggeest me what Application and table name i need to choose Thanks

  • 24" LED Cinema Display not working with Mac Pro

    I have a Mac Pro (2 x 2.4 GHz Quad-Core, model identifier MacPro5,1) purchased in late 2010 and a 24" LED Cinema Display. The Mac Pro has three video ports--a full-sized DVI and two mini DVI. When I plug the Cinema Display into either of the mini DVI

  • Problem loading a page?

    Suddenly I can not use Firefox, IE still works. When I try to use Firefox I consistently get the following message. Firefox can't find the file at jar:file:///C:/Program Files (x86)/Mozilla Firefox/omni.ja!/chrome/browser/content/browser/undefinededg