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



Home Answers Viewqa JSP-Servlet code not working properly

Have Programming Question? Ask it here!
 
 
 


ankit gupta
code not working properly
0 Answer(s)      2 years and 7 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
Not get ans properly
name (e.g emp) 6. Click "Ok" and then compile the following java code. import
Why are my variables not dividing properly?
Why are my variables not dividing properly?  Why are my variables not dividing properly
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
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
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
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
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
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
Ajax not working in jsp
Ajax not working in jsp  I'm using Netbean, Ajax validation in the following code is not working the code succesfully run for first UID validation adn also for ee-mail but does not enter if else for firstname field please help me
background images in css not working
background images in css not working  In the application i'm passing a background image from CSS in the given format ... background-image: url("Image\backgroundImage.GIF"); which is not working. So, please give me an example
calculate working hour
calculate working hour  why echo not come out? <html><body> <form action="<?php $_SERVER['PHP_SELF'];?>" method="post"> Working hour : <input name="workout" type="text"/><input name="submit1
working of a div tag in html
working of a div tag in html   !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional...; This is a simple code. but after executing it i am not getting the sentence
JTextfields working with JTextArea
JTextfields working with JTextArea  I have 2 database tables one is history the other is patient, How can I get which every patient is being... on a Jtextarea   hi friend, try the following code below : import java.sql.
Working with Eclipse IDE - Struts
Working with Eclipse IDE  hello, i am beginner to eclipse . i want to run my first struts program in eclipse 3.2. what are the steps for running struts in eclipse . Any body plz, tell me the setting environment of eclipse
command prompt is compilation is not working
command prompt is compilation is not working   Dear java users can anyone help me to run the program in command line prompt i tried by selecting the environment variable and class path and path in my system my program
datetimepicker not working in struts2
datetimepicker not working in struts2  Hi, I am using "struts2-dojo-plugin-2.1.6.jar" and the taglib is "<%@taglib prefix="d" uri="/struts-dojo-tags"%>" **sample code:** <%@taglib prefix="s" uri="/struts-tags
Multi Threading is not working in that why...?
Multi Threading is not working in that why...?   import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Date; public
ClassPathResource class is not working - Spring
ClassPathResource class is not working  Hi, Below is a sample code... ClassPathResource("hello.xml");BeanFactory factory = new XmlBeanFactory(res); Hello... parsing XML document from class path resource [classpath:hello.xml
J2ME application not working on n79
J2ME application not working on n79  Hi, i had developed assignment on sun sdk and its running fine on emulator but not showing results in two text fields on my mobile phone i.e.nokia -n79.please Help import
J2ME application not working on n79
J2ME application not working on n79  Hi, i had developed assignment on sun sdk and its running fine on emulator but not showing results in two text fields on my mobile phone i.e.nokia -n79.please Help public class MoneyL extends
J2ME application not working on n79
J2ME application not working on n79  Hi, i had developed assignment on sun sdk and its running fine on emulator but not showing results in two text fields on my mobile phone i.e.nokia -n79.please Help public class MoneyL extends
J2ME application not working on n79
J2ME application not working on n79  Hi, i had developed assignment on sun sdk and its running fine on emulator but not showing results in two text fields on my mobile phone i.e.nokia -n79.please Help public class MoneyL extends
camera roll iphone not working
camera roll iphone not working  How to access the camera in my iPhone application. Please explain.   This code explains.., how to roll... UIImagePickerController class. Find the code below.. // Create image picker controller
stuts java script validation is not working.
stuts java script validation is not working.  hello my stuts client side validation is not working. pls help me out i have put jsp file's code and validation.xml file's code. pls help --of jsp page
stuts java script validation is not working.
stuts java script validation is not working.  hello my stuts client side validation is not working. pls help me out i have put jsp file's code and validation.xml file's code. pls help --of jsp page-- > <html:form action
 

 

 

DMCA.com