code not working properly

code not working properly

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub response.setContentType("text/html"); PrintWriter out=response.getWriter(); HttpSession session=request.getSession(); session.setAttribute("lErrorMsg",null); String target="jsp/hrms_default.jsp"; String action=request.getParameter("action_submit"); //String actionchngpswd=request.getParameter("actionchngpswd"); //String username=request.getParameter("username"); System.out.println("user_name");

/* If the details are submitted with the user name and other fields */
    System.out.println(action);
    if(action.equalsIgnoreCase("hrms_user_login_submit"))
    {
        /* Requesting all the details from the jsp page */

        System.out.println("inside action_submit");
        String userId=request.getParameter("user_id");
        String userName=request.getParameter("user_name");
        String password=request.getParameter("user_password");
        System.out.println(userId);

        /* Setting the details to the bean class */

        userLogin_bean obj=new userLogin_bean();
        obj.setUser_Id(userId);
        obj.setPassword(password);
        obj.setUserName(userName);

        userLogin_model modelObj=new userLogin_model();
        System.out.println("model obj created");
        try 
        {
            boolean valid=modelObj.checkLogin(obj);
            if(valid==true)
            {
                System.out.println("user valid");
                 target="jsp/hrms_default.jsp";

            }

            else
            {
                System.out.println("invalid user");
            //  String lErrorMsg="user does not exist";
                //session.setAttribute("lErrorMsg",lErrorMsg);
                target="jsp/Hrms_user_login.jsp";


            }
            //RequestDispatcher requestDispatcher=request.getRequestDispatcher(target);
            //requestDispatcher.forward(request, response);
        }
        catch (SQLException e) 
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

    RequestDispatcher requestDispatcher=request.getRequestDispatcher(target);
    requestDispatcher.forward(request, response);

}

}

in the above code if i enter a valid username and password i am redirected to the correct page but if i enter an invalid details at the first attempt i am redirected to the correct page but after that if i again try to login using either the correct or incorrect details i am not directed to the proper page.. please help....

View Answers









Related Tutorials/Questions & Answers:
code not working properly
code not working properly  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException...); } } in the above code if i enter a valid username and password i am
Code not working
Code not working  i want to write my first applet. I wrote the java program and html code for that. while im running in appletviewer it is asking for security permissions. so, i created a policy file and linked it with html file
Advertisements
servlet not working properly ...pls help me out....its really urgent
servlet not working properly ...pls help me out....its really urgent  Hi, Below is the front page of my project 1)enty.jsp </form> </body> </html> </form> </body> </html>> <
Why is this code working
Why is this code working  Looking at this piece of code: #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct _point{ int x; int y; } point; int main (void) { point *ptr; point obj
This Query is no working in sql developer it is giving Ora-0933 exception SQL command not properly ended exception
This Query is no working in sql developer it is giving Ora-0933 exception SQL command not properly ended exception  SELECT * from employees ORDER BY first_name limit 0,10;   Hi Friend, Please clarify your problem!ADS
myJSF,Hibernate and Spring integration code is not working. - Hibernate
myJSF,Hibernate and Spring integration code is not working.  the code given in this url : http://www.roseindia.net/roseindiamembers/login.php i have tried but it does not work. when i write http://localhost
My Servlet code not working - Development process
My Servlet code not working  HHi, After executing servlet am getting blank screen. Am using weblogic server and Eclipse editor. But jsp is working fine. Steps(what i did ) 1)Created servlet (In eclipse) and export it (saved
calender working in struts - Struts
calender working in struts  when i execute the following code ,that is working properly if i convert to struts html tags that code is not working please help me to rectify the problem
how to display jsp page containing mysql query in particular division using ajax ?my code is below bt i cundt get it properly
ajax ?my code is below bt i cundt get it properly   index.html <... will display here</div> </body> </html> print("code sample...) { e.printStackTrace(); } %> 3)For the above code, we have created following table
Why are my variables not dividing properly?
Why are my variables not dividing properly?  Why are my variables not dividing properly
Not get ans properly
name (e.g emp) 6. Click "Ok" and then compile the following java code. import
JTable values are not gettiing properly
but not 9.i.e a[0][0]=8 a[0][1]= (nothing printed) Please go through my code
UITapgesturerecognizer not working
UITapgesturerecognizer not working  uitapgesturerecognizer not working
output not coming properly - JSP-Servlet
output not coming properly  I am not getting the output properly when i had written my code like below: Add Employee Details for( j=0;j<11;j++) { out.println("Department code
hibernate.archive.autodetection not working
not working. How to resolve hibernate.archive.autodetection not working issue... and example code. Thanks
Datagrid not working
Datagrid not working  The code here is working fine, apart from the fact that that I'm using netbeans 6.5 and the servlet v2.5 and struts 1.1.... working. please help me out
Button text is not displaying properly in jre 1.6.0_22 when html tags are used in the textstring
Button text is not displaying properly in jre 1.6.0_22 when html tags are used in the textstring  using html string to jbutton text is not working...(""+value+"" ); print("code sample");ADS_TO_REPLACE_1
ModuleNotFoundError: No module named 'properly-model-python'
ModuleNotFoundError: No module named 'properly-model-python'  Hi...: No module named 'properly-model-python' How to remove the ModuleNotFoundError: No module named 'properly-model-python' error? Thanks   Hi
ModuleNotFoundError: No module named 'properly-util-python'
ModuleNotFoundError: No module named 'properly-util-python'  Hi...: No module named 'properly-util-python' How to remove the ModuleNotFoundError: No module named 'properly-util-python' error? Thanks   Hi
htpasswd working
htpasswd working   hii, What does htpasswd do?   hello,ADS_TO_REPLACE_1 htpasswd creates a new user in a specified group, and asks to specify a password for that user
html dropdown not working firefox
html dropdown not working firefox  I am writing a Dropdown code in HTML which is not working in firefox. What could be the reason as it's perfectly working in IE and Crome. Thanks
Why this is not working...?
Why this is not working...?  import java.util.*; public class Family { int size_of_family=0; public Person[] members=new Person[size_of_family...); f.printOutFamily(); } }   Post the code of Student.java
Update not working in hibernate.
Update not working in hibernate.  Update not working in hibernate
Comparing arrays not working correctly?
Comparing arrays not working correctly?  Comparing arrays not working correctly
Dynamic-update not working in Hibernate.
Dynamic-update not working in Hibernate.  Why is dynamic update not working in hibernate?   Dynamic-update is not working. It means when... am giving you a small block of code for updating of employee detail- public
Nitobi Grid is not working in IE10/IE11
Nitobi Grid is not working in IE10/IE11  Nitobi grid is working in IE8, but not working in IE10/IE11. we are using above two javascript files to open the grid
Focus method not working in firefox
Focus method not working in firefox  object.focus() is not working in firefox and chrome the element is not focused what was the problem
StandardServiceRegistryBuilder not working in Hibernate 4.3.1
StandardServiceRegistryBuilder not working in Hibernate 4.3.1  Hi, It seems that the StandardServiceRegistryBuilder not working in Hibernate 4.3.1. I don't know what is wrong with the following code: Configuration cfg = new
ModuleNotFoundError: No module named 'working'
ModuleNotFoundError: No module named 'working'  Hi, My Python... 'working' How to remove the ModuleNotFoundError: No module named 'working... to install padas library. You can install working python with following command
ModuleNotFoundError: No module named 'working'
ModuleNotFoundError: No module named 'working'  Hi, My Python... 'working' How to remove the ModuleNotFoundError: No module named 'working... to install padas library. You can install working python with following command
ModuleNotFoundError: No module named 'working'
ModuleNotFoundError: No module named 'working'  Hi, My Python... 'working' How to remove the ModuleNotFoundError: No module named 'working... to install padas library. You can install working python with following command
Working Example for Spring AOP - Spring
Working Example for Spring AOP  Hi All, I need a complete working Java example /Code/Logic for Spring -Aspect Oriented Programming. Code provided will be highly appreciated. -- Deepak Lal
php <? ?> tag not working
php tag not working  why PHP tags not working in my application?   This might happen when your shortopentag is turned off. So, you...("shortopen_tag", 1); in your code; add the following line to your .htaccess file
file_exists php not working
file_exists php not working  file_exists php not working. Please give me the simple example
r set working directory
r set working directory  Hi, How to set working directory in r.... There are command to set the working directory in R. Working directory is the base... project. After setting working directory you can load data files without providing
Sql querry not working
of slabs. CBID is cutblock ID. My code: ResultSet rc=st.executeQuery("select... should get ROWCOUNT:1 For the first two times my query is getting executed properly
JOptionPane.showMessageDialog is not working on tomcat however it is working on netbeans on same machine
JOptionPane.showMessageDialog is not working on tomcat however it is working on netbeans on same machine  the following code is not running on apacheTomcat 7.0.30 version but the same code is working on netebans 7.0, how to make
window.open() not working - Ajax
is that the pop up window is not at all working.. Once I click the button, the page... I went wrong, in the above piece of code.. Regards, Ragavendran.R  
Code
Code  code for connecting c lang to database
code
code    how to write this in java
code
code  code for android sample program
code for this is
code for this is  a b c d c b a a b c c b a a b b a a a code
code
code  please provide code for custom tags.by using currdate tag we need to get current date?please give me code
code
code   hi I need help in creating a java code that reminds user on a particular date about their festival. i have no clue of how to do it.. am looking forward to seek help from you
code
the correct code for a program.The output of the program is listed below...: {Block 5} ADDRESS-3: {San Juan} POST CODE:{6745} ENTER CODE (XX TO stop) CODE:{FF1} QUANTITY:{2} CODE:{TR4} QUANTITY:{1} CODE:XX INVOICE FOR YOUR ORDER Harry
code
code to create the RMI client on the local machine: import java.rmi.*; public... : "+e); } } } However, when the preceding code is executed it results... the correct code
Working of POS Terminal
Working of POS Terminal  Hi there, thanks for this post. Just curious how actual POS terminal will interact with PHP. PHP doesn't provide hardware interaction. Thanks for reply. Regards. (adsbygoogle
UIWebView zoom not working
UIWebView zoom not working  Hi, I don't know why UIWebView zoom not working? Tell the solution. Thanks   Hi, Open the .xib file and set scalesPageToFit to YES. Thanks
code
code  i have four textboxes.whenever i click on up,down,left or down arrows then the cursor move to another textbox based on the key pressed.i want code for this in javascript
code
line of code to print the amount he should be paid as allowance

Ads