Login Form using struts

i'm new to struts...
can anyone help me out...with
Sample code that helps to build a login in form using struts ,that has interaction with data base...
kindly drop mail @ [email protected]

i'm new to struts...
can anyone help me out...withYou should look for a Struts forum, or post in the JSP forum here.
Sample code that helps to build a login in form using
struts ,that has interaction with data base...Google search.
kindly drop mail @ [email protected]
It could also mean spam. I advise against posting email addresses in public forums.

Similar Messages

  • To create login form using swing with sqlserver as backend

    hi.
    can anybody send me code to create login form using swings .
    thnaks in advance..
    sj

    You do realise that you can't create Swing on a JSP page?
    You have to use HTML.
    If you want to use Swing, the java must be running at the client end, which means you need an Applet, and a completely different forum.

  • Login form using JSC n MySql

    please send me full code for a simple login page using my jsc n mysql

    here i hav got code for a simple login form usin
    JAVA and MySQl
    public String button1_action() {
    String Username = (String) this.textField1.getValue();
    String pwd = (String) this.passwordField1.getValue();
    boolean isValidUser=false;
    com.sun.sql.rowset.CachedRowSetXImpl loginRowSet=new com.sun.sql.rowset.CachedRowSetXImpl();
    try {
    loginRowSet.setDataSourceName("java:comp/env/jdbc/sms");
    loginRowSet.setCommand("SELECT * FROM login");
    loginRowSet.setTableName("login");
    loginRowSet.execute();
    loginRowSet.beforeFirst();
    while(loginRowSet.next()){
    String Username1 = loginRowSet.getString("name");
    String Password1 = loginRowSet.getString("password");
    if(Username.equals(Username1) && pwd.equals(Password1)){
    return "case1";
    if (!isValidUser){
    staticText1.setValue( " logon failed");
    catch (Exception e) {
    error("Login Failed : " + e.getMessage());
    throw new FacesException(e);
    } finally {
    loginRowSet.close();
    return null;
    Make some changes in session bean also
    protected ApplicationBean1 getApplicationBean1() {
    return (ApplicationBean1)getBean("ApplicationBean1");
    plz add this also
    public boolean do_rand() {
    boolean do_rand = true;
    try{
    loginRowSet.setCommand("SELECT * FROM login ");
    }catch(SQLException ex) {
    if(ex != null ){
    ex.printStackTrace();
    errorRand = "error do random";
    do_rand = false;
    return do_rand;
    } catch(Exception e) {
    e.printStackTrace();
    return false;
    return true;
    }

  • Login form using Access... (in JSP )

    I have written the following code in JSP and connected to Access Database.
    Aftre i run the JSP from browser the Login form is displayed. but aftre i enter the "userid" and "password" nothing hapens. the application is STUCK !!
    <HTML>
    <HEAD>
    <TITLE> Login </TITLE>
    <script language="Javascript">
    function giveFocus()
         document.login.user.focus()
    function submitForm()
         document.login.submit()
    function resetForm()
         document.login.reset()
         document.passwd.reset()
         document.login.user.focus()
    </script>
    </HEAD>
    <BODY onload="giveFocus()">
    <form name="login" method="post" action="http://localhost//dcs/forward.jsp">
    <table border="0" cellpadding="2" cellspacing="0" width="80%"> <tr><td bgcolor="#ffffff" align="center">
    <table border="0" cellspacing="6" cellpadding="6" bgcolor="ffffff" width="80%" height="280">
    <tr bgcolor="#ADADAD">
    <td align="center"><font face="Verdana" SIZE="5">LOGIN FOR DDM</font><br>
    <table border=0 cellpadding=4 cellspacing=0>
    <tr> <td align="right">
    <P ALIGN="LEFT"><font face="Verdana" size="3"><BR>Please enter your ID and password
    <table border=0 cellpadding=10 cellspacing=10>
    <tr>
         <td align="right" ><font face="Verdana" size="4">User Id   :</font></td>
         <td><font face="arial" size="-1"><b></b></font><input name="user" type="text" length="9" maxlength="9"></td>
    </tr>
    <tr>
         <td align="right" ><font face="Verdana" size="4">Password  :</font></td>
         <td><input name="passwd" type="password" length="8" maxlength="8"></td>
    </tr>
    <tr>
         <td align=center valign=bottom>
         <input type="submit" name="login" value="     LOGIN     "  ></td>
    <td align=center valign=bottom><input type="button" name="cancel" value="   Cancel    " ></td>
    <td align=center valign=bottom><input type="submit"  name="chgp" value="Change Password"></td>
    </tr>
    </table>
    </table>
    </table>
    </table>
    </form>
    </body>
    </html> Kindly tell me wht is the problem with my code ? ?

    http://forum.java.sun.com/thread.jspa?threadID=599315&tstart=0
    Cross-post

  • Login form using Access(JSP)....

    I have written the following code in JSP and connected to Access Database.
    Aftre i run the JSP from browser the Login form is displayed. but aftre i enter the "userid" and "password" nothing hapens. the application is STUCK !!
    <HTML>
    <HEAD>
    <TITLE> Login </TITLE>
    <script language="Javascript">
    function giveFocus()
         document.login.user.focus()
    function submitForm()
         document.login.submit()
    function resetForm()
         document.login.reset()
         document.passwd.reset()
         document.login.user.focus()
    </script>
    </HEAD>
    <BODY onload="giveFocus()">
    <form name="login" method="post" action="http://localhost//dcs/forward.jsp">
    <table border="0" cellpadding="2" cellspacing="0" width="80%"> <tr><td bgcolor="#ffffff" align="center">
    <table border="0" cellspacing="6" cellpadding="6" bgcolor="ffffff" width="80%" height="280">
    <tr bgcolor="#ADADAD">
    <td align="center"><font face="Verdana" SIZE="5">LOGIN FOR DDM</font><br>
    <table border=0 cellpadding=4 cellspacing=0>
    <tr> <td align="right">
    <P ALIGN="LEFT"><font face="Verdana" size="3"><BR>Please enter your ID and password
    <table border=0 cellpadding=10 cellspacing=10>
    <tr>
         <td align="right" ><font face="Verdana" size="4">User Id   :</font></td>
         <td><font face="arial" size="-1"><b></b></font><input name="user" type="text" length="9" maxlength="9"></td>
    </tr>
    <tr>
         <td align="right" ><font face="Verdana" size="4">Password  :</font></td>
         <td><input name="passwd" type="password" length="8" maxlength="8"></td>
    </tr>
    <tr>
         <td align=center valign=bottom>
         <input type="submit" name="login" value="     LOGIN     "  ></td>
    <td align=center valign=bottom><input type="button" name="cancel" value="   Cancel    " ></td>
    <td align=center valign=bottom><input type="submit"  name="chgp" value="Change Password"></td>
    </tr>
    </table>
    </table>
    </table>
    </table>
    </form>
    </body>
    </html> Kindly tell me wht is the problem with the code ? ? ?

    the code for doing the connection between JSP and Access is as follows :
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection conn = DriverManager.getConnection("jdbc:odbc:rupa","system","manager");rupa is DSN which i created for MS ACCESS
    is this ok?

  • Trying to create a login form using j_security_check

    Ok, here's the deal.
    I have a login.jsp that uses the j_security_check. The page works great if I request a protected resource and the container forwards me to the login page.
    However, if I access the login page directly "http:/server/app/login.jsp" and submit the form I get a 404 "Page not found" error. This really stinks because I need to add the login fields to the index page of the site and allow people to login at their discreation (only peices of the site are protected, but unprotected pieces have different functionality for logged in users). From personal experience Tomcat, JRun and WebSphere allow you to post to the j_security_check uri at anytime. What's the deal?

    Steve,
    Directly going to login page will not work because "j_security_check" cannot work independently and is supposed to work in conjuction with a protected URL.
    I looked at Servlet specification (Section 11.5.3 of Servlet 2.2) and this does not say anything about directly going to login page.
    You can create an index page and have that secured and whenever users can try to access that page they will be forwarded to the login page.
    You may use Programmatic Security if Declarity security is insufficient for you.
    regards
    Debu

  • Dynamic population of a form using Struts

    Right now I have a combo box and a textbox. My combo box is populated by:
    <html:select property="departmentName" onchange="changeDescription()">
      <html:options collection="departmentList" property="name" labelProperty="name"/>
    </html:select>My textbox is declared as:
    <html:text property="description"/>Ok so my problem now is coding that changeDescription() javascript method so that whenever a change in the combo box's selection is made, the textbox will be populated by another property "description". I can easily make the textbox populate with the same property "name" by using this:
    function changeDescription() {
      document.forms[0].description.value = document.forms[0].departmentName.value;
    }but how do I do it for another property?
    I would greatly appreciate any help! Thanks!

    I'm a bit confused by the question. Are you saying that you want the textbox to automatically update it's value everytime the combo box's currently selected item is changed. And you want the value assigned to the textbox to come from some place other than the value of the currently selected combobox item. Where should the value for the textbox come from? Looking at this it seems like you may want a simple map data structure that maps each combo box element to a description string. When the combo box is modified you should grab the currently selected element and lookup the description for that element in the map data structure and then set the textbox to the looked-up description. I may be missing something here..

  • Help required with login form using applet

    this is the code I'm working on. it does not show any errors but it does not successfully authenticate the login either.
    please help
    public class Loginex extends JApplet implements ActionListener
         public JPanel p;
         public JLabel l1,l2;
         public JTextField t1;
         public JPasswordField pw1;
         public JButton signin;
         public String uname,upwd,dname,dpwd;
         public void init()
              JPanel p=new JPanel();
              JLabel l1=new JLabel("Username");
              JLabel l2=new JLabel("Password");
              JTextField t1=new JTextField(20);
              JPasswordField pw1=new JPasswordField(20);
              JButton signin=new JButton("Sign in");
              p.add(l1);
              p.add(t1);
              p.add(l2);
              p.add(pw1);
              p.add(signin);
              signin.addActionListener(this);
              add(p);
              uname=t1.getText();
              upwd=pw1.getText();
         public void actionPerformed(ActionEvent ae)
              if(ae.getSource()==signin)
                   System.out.println("You are trying to login as : "+uname);
              try
                   Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
                   Connection
    con=DriverManager.getConnection("jdbc:sqlserver://localhost;"+"user=sa;password=sysdba;"+"database=job_app");
                   Statement stm = con.createStatement();
                   String query = "SELECT emp_id, emp_pwd FROM Employee where emp_id= "+uname +";";
                   ResultSet rs = stm.executeQuery(query);
                   while(rs.next())
                        dname=rs.getString("emp_id");
                        dpwd=rs.getString("emp_pwd");
                        if((dname.equals(uname))&&(dpwd.equals(upwd)))
                             System.out.println("You are logged in as : "+uname);
                        else
                             System.out.println("Login failed");
                   rs.close();
                   stm.close();
                   con.close();
              catch(Exception e)
                   System.out.println("Error occured"+e);
    }

    njb7ty wrote:
    Also, if uname had a single quote such as O'Conner, the originial sql statement would fail unless you properly escape the single quote. With preparedStatements, you dont have to escape it. I also believe preparedStatements are less suseptable to sql injection attacks.You are correct, prepared statements are the best thing since sliced bread. They are:
    - easier to read and write
    - easier to debug
    - run faster if used more than once
    - and are not susceptible to SQL injection attacks, this is especially important if the data being used in the parameter came in over the internet.
    I always use them, even when they might be slightly less efficient, eg. where I build the SQL right before I prepare it and then never use it again.

  • Register & login form using shareobject ????

    Hello Developers,
    1 - How can i create register and login page in flash and i want to use shareobject please guide me, how can i use sharedobject.
    2-  How can i use mysql database to connect flash ...
    Please HELP ME !!!

    1.  normally, a sharedobject would play no role in a login page except to autofill the login for re-visits.
    2.  use the urlloader class to call server-side script that communicates with your database.

  • I want to create a login form by using servlets with database validation.

    Would you please provide me a code for a login form using servlets with Ms Access database validation?

    No. This is not a free coding service. Your request is (a) ridiculous, (b) offensive, and (c) off-topic. Locking this thread for later deletion.

  • Need some help in the login form ???!?!?!?!!

    can any one help me with correcting the code or can any one give me another code for using it in the login form.
    this is my problem:-
    i had make a login form using in oracle 9i form builder >>>in this form i have three text boxes one for intering user name and the second one for entering the password and the third text box is not visible and it is used for counting the tries.
    In addition i have a three buttons , one is for login and the two others are not visible and they are a show main menu button and a exit button. For login button i had put a WHEN-BUTTON-PRESSED trigger in the login button and it must check if the user name and the password match what it is on the login table so it allow the user to see the show main menu button otherwise if the user name or the password are wrong and has been putted wrong for 3 times of trying then it will show the exit button.
    and this is a picture of the login form in the design view.
    http://www.al7loh.com/uploader/uploads/login.JPG
    and this is the code for theWHEN-BUTTON-PRESSED trigger on the login button
    declare
         alertNum number;
    dummy1 tbl_login.USER_NAME%type;
         dummy2 tbl_login.PASS%type;
    begin
         select tbl_login.USER_NAME, tbl_login.PASS into dummy1, dummy2 from tbl_login where tbl_login.USER_NAME = :LOGIN.USER_NAME and
         tbl_login.PASS = :LOGIN.PASS;
         if :LOGIN.TRIES<3 then
         if sql%found
              then
              set_item_property('LOGIN.SHOW_MENU', visible, property_true);
                                                                               set_item_property('LOGIN.SHOW_MENU', enabled, property_true);
                                                                               else
                                                                               message ('Invalid password....try again');
                                                                               :LOGIN.TRIES := :LOGIN.TRIES+1;
                                                                               :LOGIN.USER_NAME := null;
                                                                               :LOGIN.PASS := null;
                                                                                    end if;
         else
         message ('Exceeded Number of tries..press exit button');
              set_item_property('LOGIN.EXIT', visible, property_true);
                   set_item_property('LOGIN.EXIT', enabled, property_true);
         end if;
         end;
    can any one help me correcting the code of the WHEN-BUTTON-PRESSED trigger on the login form or can any one give me another code for using it in the login form.
    i hope to get some help from the experts>>> ??!?!?!?!?!

    Something like this
    declare
      alertNum number;
      dummy1 tbl_login.USER_NAME%type;
      dummy2 tbl_login.PASS%type;
    begin
      Begin
        select tbl_login.USER_NAME, tbl_login.PASS
        into   dummy1, dummy2
        from   tbl_login
        where  tbl_login.USER_NAME = :LOGIN.USER_NAME
        and    tbl_login.PASS = :LOGIN.PASS;
        set_item_property('LOGIN.SHOW_MENU', visible, property_true);
        set_item_property('LOGIN.SHOW_MENU', enabled, property_true);
      Exception
        When no_data_found Then
          if :LOGIN.TRIES<3 then
            message ('Invalid password....try again');
            :LOGIN.TRIES := :LOGIN.TRIES+1;
            :LOGIN.USER_NAME := null;
            :LOGIN.PASS := null;
            Go_Item( 'LOGIN.USER_NAME' ) ;
          else
            message ('Exceeded Number of tries..press exit button');
            set_item_property('LOGIN.EXIT', visible, property_true);
            set_item_property('LOGIN.EXIT', enabled, property_true);
          end if;
      end;
    end;Francois

  • Customize expired password login form

    Hi,
    On the expired login form I don't want to display the resource accounts table so the user can change only Lighthouse password if the password is expired.
    since expired login form uses User Form Library, I copied the default one and renamed it and modified the customized User Form Library accordingly. I managed to removed the resource accounts table so that it displays only 2 text boxes Confirm Password and Confirm New Password. After entering the password and when I click on the Change Password button it displays error "Must Select Atleast one resource account".
    The Change Password button is doing some validation, and I am not sure in which form library this button is defined. I checked in Change Password Form it contains buttons but I don't see any validation on these buttons.
    Where exactly the Change Password button is defined?
    Is there any other way to customize the expire login form?
    Any ideas please..
    Thanks
    Edited by: idmus on May 19, 2010 1:24 PM

    What you describe should work, you just need to simulate the user selecting one or more resources.
    So somewhere on the form put code like:
        <Field name='resourceAccounts.currentResourceAccounts[RESOURCE].selected'>
            <Expansion>
                <s>true</s>
            </Expansion>
        </Field>This acts as if the user has selected a resource. Kind of a weird way to do it, but there you go.
    Edited by: etech on May 24, 2010 4:38 PM
    Edited by: etech on May 24, 2010 4:39 PM

  • Set "peoples or groups" field with current user "login name" in sharepoint list form using javascript

    hi friends
    i am trying to set peoples or groups field in sharepoint  list form with current user login name
    here my code
    <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.js"></script>
    <script type="text/javascript">
    $(document).ready(function NewItemView () {
    var currentUser;
        if (SP.ClientContext != null) {
          SP.SOD.executeOrDelayUntilScriptLoaded(getCurrentUser, 'SP.js');
        else {
          SP.SOD.executeFunc('sp.js', null, getCurrentUser);
        function getCurrentUser() {
          var context = new SP.ClientContext.get_current();
          var web = context.get_web();
          currentUser = web.get_currentUser();
          context.load(currentUser);
          context.executeQueryAsync(onSuccessMethod, onRequestFail);
        function onSuccessMethod(sender, args) {
          var account = currentUser.get_loginName();
          var accountEmail = currentUser.get_email();
          var currentUserAccount = account.substring(account.indexOf("|") + 1);
        SetAndResolvePeoplePicker("requester",account);
    // This function runs if the executeQueryAsync call fails.
        function onRequestFail(sender, args) {
          alert('request failed' + args.get_message() + '\n' + args.get_stackTrace());
     function SetAndResolvePeoplePicker(fieldName, userAccountName) {
       var controlName = fieldName;
        var peoplePickerDiv = $("[id$='ClientPeoplePicker'][title='" + controlName + "']");
        var peoplePickerEditor = peoplePickerDiv.find("[title='" + controlName + "']");
        var spPeoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict[peoplePickerDiv[0].id];
        peoplePickerEditor.val(userAccountName);
        spPeoplePicker.AddUnresolvedUserFromEditor(true);
    </script>
    but it is not working
    please help me

    Hi,
    According to your post, my understanding is that you wanted to set "peoples or groups" field with current user "login name" in SharePoint list form using JavaScript.
    To set "peoples or groups" field with current user "login name”,  you can use the below code:
    <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.js"></script>
    <script type="text/javascript">
    function SetPickerValue(pickerid, key, dispval) {
    var xml = '<Entities Append="False" Error="" Separator=";" MaxHeight="3">';
    xml = xml + PreparePickerEntityXml(key, dispval);
    xml = xml + '</Entities>';
    EntityEditorCallback(xml, pickerid, true);
    function PreparePickerEntityXml(key, dispval) {
    return '<Entity Key="' + key + '" DisplayText="' + dispval + '" IsResolved="True" Description="' + key + '"><MultipleMatches /></Entity>';
    function GetCurrentUserAndInsertIntoUserField() {
    var context = new SP.ClientContext.get_current();
    var web = context.get_web();
    this._currentUser = web.get_currentUser();
    context.load(this._currentUser);
    context.executeQueryAsync(Function.createDelegate(this, this.onSuccess),
    Function.createDelegate(this, this.onFailure));
    function onSuccess(sender, args) {
    SetPickerValue('ctl00_m_g_99f3303a_dffa_4436_8bfa_3511d9ffddc0_ctl00_ctl05_ctl01_ctl00_ctl00_ctl04_ctl00_ctl00_UserField', this._currentUser.get_loginName(),
    this._currentUser.get_title());
    function onFaiure(sender, args) {
    alert(args.get_message() + ' ' + args.get_stackTrace());
    ExecuteOrDelayUntilScriptLoaded(GetCurrentUserAndInsertIntoUserField, "sp.js");
    </script>
    More information:
    http://alexeybbb.blogspot.com/2012/10/sharepoint-set-peoplepicker-via-js.html
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Oracle ADF 11g – Authentication using Custom ADF Login Form Problem

    Hi Guys,
    I am trying to Authenticate my adf application using custom Login Form.
    following this..
    http://www.fireboxtraining.com/blog/2012/02/09/oracle-adf-11g-authentication-using-custom-adf-login-form/#respond
    But my Login Page is not Loading.I think its sending request in chain.my jdev version is 11.1.1.5.Any Idea.
    Thanks,
    Raul

    Hi Frank,
    I deleted bounded code and In another Unit Test I created a simple login.jspx page and applied form based authentication but still facing same problem means something wrong in starting.
    My login.jspx page is
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
      <jsp:directive.page contentType="text/html;charset=UTF-8"/>
      <f:view>
        <af:document id="d1" >
          <af:form id="f1" >
            <af:panelFormLayout id="pfl1">       
              <af:inputText label="USERNAME" id="it1"
                            />       
              <af:inputText label="PASSWORD" id="it2"
                              />
              <af:commandButton text="LOG IN" id="cb1" />
              <f:facet name="footer">       
              </f:facet>                 
            </af:panelFormLayout>
          </af:form>
        </af:document>
      </f:view>
    </jsp:root>
    Don't know wht real problem is

  • How to create different login form pages using Extranetlook

    Hi,
    I would like to have different login pages in order to let users access to different sites created with Site Studio. The Extranetlook component comes with a default one, login_page.htm but if I change this file, then this login page is used for all users in the whole Content Server. Our requirement is to have different login pages, one per each site, and let the default one to let users access just the Content Server, not the sites.
    We created a custom login form page copying the login_page.htm file and then modified the redirecturl input field (<input value="/oursite/" type="hidden" name="redirecturl" />). This only works when the login is successful. When the login is incorrect the user is redirected to the default login_page.htm. In that case, we would like to redirect the user to custom login form instead of the default one.
    In fact, I'm afraid I don't understand well the relation between the login_page.htm within the component, the login_page.htm file that resides in <ucm-installation>/data/users and the extranetlook.idoc file.
    Thanks in advance.

    While not resolving issue with multisite login page, i can tell the relationship among component login_page, data user login_page and ExtranetLook.idoc.
    So according to component readme.txt ExtranetLook.idoc is used to construct user data login_page (i've checked it). So any customizations made to its dynamic html sections are reflected into that file - and it is the which being showed in browser. The component one is used as initial one.

Maybe you are looking for