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



Home Answers Viewqa JSP-Servlet code not working properly
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


ankit gupta
code not working properly
0 Answer(s)      2 years and 11 months ago
Posted in : JSP-Servlet


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....


Advertisement
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>> <
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
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
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
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
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
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
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
UITapgesturerecognizer not working
UITapgesturerecognizer not working  uitapgesturerecognizer not working
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
htpasswd working
htpasswd working   hii, What does htpasswd do?   hello, htpasswd creates a new user in a specified group, and asks to specify a password for that user
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
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
Comparing arrays not working correctly?
Comparing arrays not working correctly?  Comparing arrays not working correctly
Update not working in hibernate.
Update not working in hibernate.  Update not working in hibernate
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
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
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
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
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
file_exists php not working
file_exists php not working  file_exists php not working. Please give me the simple example
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  
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
 

 

 

DMCA.com