Jgalcambra/or any one i need ur help please...

i have anew problem .......... very intresting one..
in my project i use jsp as my front end , database is mssql , web server is apache tomcat........am also using servelts along with these jsp ....
even tomcat is running i am able to open jsp files....
in my project i mean in the front end there is login page for user id & pass word.....when i enter values in those fields i am not able to login..
i am getting an errorpage sayin incorrect login which is designed by me only... i have already haviv these user name & password in my my database.... login page has to basically verify the input values whatever we give with these database values & go to next page but this is not happening....i am not gettin any sort of syntax error....can u please help me in fixin this problem

i checked out all these things...the data is being retrieved from the database and the parameters being passed are also being assigned properly...the two values are not being compared properly and hence access is not allowed...the same code worked on a different system..here is the code....
the following is the servlet:
import java.io.IOException;
import java.io.PrintStream;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.*;
import javax.servlet.http.*;
public class ELogin extends HttpServlet
    public ELogin()
    public void service(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
        throws ServletException, IOException
        httpservletresponse.setContentType("text/html");
        java.io.PrintWriter printwriter = httpservletresponse.getWriter();
        String s  = httpservletrequest.getParameter("uid");
        String s1= httpservletrequest.getParameter("pw");
        String s2 = httpservletrequest.getParameter("dep");
        int i=1;       
        try
            HttpSession httpsession = httpservletrequest.getSession(true);
            Date date = new Date();
            SimpleDateFormat simpledateformat = new SimpleDateFormat("h:mm a");
            String s3 = simpledateformat.format(date);
            Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
            Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:3413;DatabaseName=Project", "Product", "product");
            Statement statement = connection.createStatement();
            ResultSet resultset1 = statement.executeQuery(" select * from emp_log ");
            boolean flag = false;
            do
                i++;
                if(!resultset1.next())
                    break;
                user1 = resultset1.getString(1);
                pass1 = resultset1.getString(2);
                Dep1  = resultset1.getString(3);
/* i think the problem is in the following part of the code*/
                if(s.equals(user1) && s1.equals(pass1) && s2.equals(Dep1))
                    javax.servlet.ServletConfig servletconfig = getServletConfig();
                    RequestDispatcher requestdispatcher = getServletContext().getRequestDispatcher("/Activity.jsp");
                    httpsession.setAttribute("Empname", s);
                    httpsession.setAttribute("Depname", s2);
                    httpsession.setAttribute("loginTime", s3);
                    httpsession.setMaxInactiveInterval(0x3938700);
                    requestdispatcher.forward(httpservletrequest, httpservletresponse);
                    flag = true;
            } while(true);
            if(!flag)
                String s4 = "Wrong Password,Please retype!!!";
                httpsession.setAttribute("DepError1", s4);
                httpsession.setMaxInactiveInterval(0x3938700);
                RequestDispatcher requestdispatcher2 = httpservletrequest.getRequestDispatcher("/ErrorPageForEmpLogin.jsp");
                requestdispatcher2.include(httpservletrequest, httpservletresponse);
        catch(Exception exception)
            System.out.println((new StringBuilder()).append("SQLException: ").append(exception).toString());
    static String user1;
    static String pass1;
    static String Dep1;
    static String DepErrorInEmp;
    static String DepErr;
    static String user2;
    static String pass2;
    static String Dep2;
    static String DepErrorInAdmin;
    static String DepErr1;
this is the login page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ page language="java" import="java.util.* ,java.text.SimpleDateFormat ,java.sql.*" %>
<% java.util.Date  todayDate = new java.util.Date();
   int month = todayDate.getMonth()+1;
   int date = todayDate.getDate();
   int year = todayDate.getYear()+1900;
   int time = todayDate.getHours();
   String dateOnly = Integer.toString(month)+ "/" + Integer.toString(date)+ "/" +Integer.toString(year);%>
<html>
<html>
<head>
<title> Activity </title>
<script language="javascript" >
function showText()
  var thetime=new Date();
  var nhours = <%= todayDate.getHours()%>;
  var nmins = <%= todayDate.getMinutes()%>;
  var nsecn = <%= todayDate.getSeconds()%>;
  var AorP=" ";
/*if (nhours>=12)
    AorP="P.M.";
else
    AorP="A.M.";*/
if (nhours>=25)
    nhours-=24;
if (nhours==0)
nhours=12;
if (nsecn<10)
nsecn="0"+nsecn;
if (nmins<10)
nmins="0"+nmins;
if (nhours<10)
nhours="0"+nhours;
  document.clockform.clockStart.value=nhours+":"+nmins+":"+nsecn+" "+AorP;
document.getElementById("time").style.display = '';
</script>
<SCRIPT language="JavaScript">
function startclock()
var thetime=new Date();
var nhours=thetime.getHours();
var nmins=thetime.getMinutes();
var nsecn=thetime.getSeconds();
var AorP=" ";
/*if (nhours>=12)
    AorP="P.M.";
else
    AorP="A.M.";*/
if (nhours>=25)
    nhours-=24;
if (nhours==0)
nhours=12;
if (nsecn<10)
nsecn="0"+nsecn;
if (nmins<10)
nmins="0"+nmins;
document.clockform.clockEnds.value=nhours+":"+nmins+":"+nsecn+" "+AorP;
setTimeout('startclock()',1000);
</script>
<script language="javascript" type="text/javascript">
function submitAddfunction()
    var type = document.clockform.At;
         if(type.value == "Select")
       window.alert("Please select activity type");
       type.focus();
     else
       document.clockform.action="http://10.32.244.169:8082/Activity/Add";
          document.clockform.submit();
function submitLogfunction() 
  { //if(i==2)
    var x = window.confirm("Do you want to logout?");
    if (x)
     document.clockform.action="http://10.32.244.169:8082/Activity/Logout";
     document.clockform.submit();
   else
      var type=document.clockform.At;
      type.focus();
</script>
</head>
<body background="background1.JPG" onLoad="startclock()">
<font face= "verdana" size="4" color=#804000>Version 1</font> <br><br>
<%   String userName = (String)session.getAttribute("Empname");
     session.setAttribute("Empname",userName);
     String depName = (String)session.getAttribute("Depname");
     session.setAttribute("Depname",depName);
     String LoginTime = (String)session.getAttribute("loginTime");
     session.setAttribute("loginTime",LoginTime);
     session.setMaxInactiveInterval(60000000); %>
<font face= "verdana" size="6" color=#804000>Welcome <%=userName%></font>
<form name="clockform"><br><br>
<font face= "verdana" size="4" color=#400000>
<div  style="position:absolute; left:30px; top:120px; width:750px; height:323px;">
  Current Time:</font><font size="2" color=#400000> <%= todayDate %></font><br><br><br><br><br><br>
  '<%=depName%>'
<INPUT TYPE="text" name="Dep"  size="12" value = '<%=depName%>'  style="visibility:hidden" ><br>
<INPUT TYPE="text" name="user" size="12" value = '<%=userName%>' style="visibility:hidden" >
<div  style="position:absolute; left:150px; top:100px; width:750px; height:323px;">
<font face= "verdana" size="4" color=#400000>
<center><table>
<div  style="position:absolute; left:10px; top:10px; width:750px; height:323px;"> Login Time</div>
<div  style="position:absolute; left:150px; top:10px; width:750px; height:323px;">
  <input type=text name="logintime" size="6" value='<%= LoginTime %>'  readonly ></div>
<div  style="position:absolute; left:300px; top:10px; width:750px; height:323px;"> Date</div>
<div  style="position:absolute; left:350px; top:10px; width:750px; height:323px;">
  <input type=text name="date" size="8" value='<%= dateOnly %>'  readonly > </div>
<div  style="position:absolute; left:10px; top:50px; width:750px; height:323px;">Activity Type</div>
<div  style="position:absolute; left:150px; top:50px; width:750px; height:323px;">
  <select name="At" onChange="showText()">
     <option value="Select">--Select--</option>
       <%
         Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
         Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:3413;DatabaseName=Project", "Product", "product");
         Statement st = con.createStatement();
         ResultSet rs = st.executeQuery(" select Activity_Type from Dep_names where Dep_name='"+depName+"'");%>
       <% while(rs.next())
               String Activity=rs.getString(1);
              StringTokenizer z = new StringTokenizer(Activity, ",");
            while(z.hasMoreTokens())
          {%>
              <option><%=z.nextToken()%></option>
           <%}
         }%>
  </select></div>
<div  style="position:absolute; left:10px; top:90px; width:750px; height:323px;">Started Time</div>
<div  style="position:absolute; left:150px; top:90px; width:750px; height:323px;">
  <input type=text name="clockStart" id="time"   size="6" style="display:none" readonly></div>
<div  style="position:absolute; left:10px; top:130px; width:750px; height:323px;">End Time</div>
<div  style="position:absolute; left:150px; top:130px; width:750px; height:323px;">
  <INPUT TYPE="text" name="clockEnds" size="6"  readonly>
</div>
<div  style="position:absolute; left:10px; top:170px; width:750px; height:323px;">Comments</div>
<div  style="position:absolute; left:150px; top:170px; width:750px; height:323px;">
  <textarea name="comment" cols="50" rows="6" > </textarea>
</div><br><br><br>
<div  style="position:absolute; left:145px; top:290px; width:750px; height:323px;">
  <input type=button TITLE="Click here to add ur record" name="add" value=" ADD "  onClick="submitAddfunction()" >
  <input type="button" TITLE="View Records" name="view" value="View"                onClick="javascript:window.open('http://10.32.244.169:8082/Activity/XlEmployeeReports.jsp');">
  <input type=button name="logout" value=" Logout "  onClick="submitLogfunction()">
</div>
</table>
</center>
</font>
</div>
</form>
from the jsp page U R accessing servlet & in servlet comparision is taking place..............
thanks in advance
</body>
</html>

Similar Messages

Maybe you are looking for

  • X3-02 Sending and receiving mms messages

    I got this phone for xmas and having problems sending and receiving photos, please could someone explain what I need to set. Thank you

  • Any way to change speed of a clip in "over-write edit" mode?

    I want to change the speed of a clip in the timeline without having to lock all the other tracks or having to move the other following clips out of sync. For example I have a clip which lasts for 1 sec, which I want to change to 3 secs. Normally when

  • BI Content 3.5.3 and xRPM 4.0

    Hi I am currently working on xRPM 4.0. I need to know that can we use BI Content 3.5 on the source system(R/3 4.7) as a plugin with xRPM 4.0. In the xRPM masterguide it states BI content 7.0 version is required. Also will it create any consistency is

  • Whats up with my macbook pro?

    the mouse, (trackpad) has been moving on its own, randomly "right "clicking on things, and zooming in and out of things. or just zooming and staying zoomed in, this all happens without me touching the trackpad. when i do touch to move the cursor, or

  • Problem floppy disk

    How I configure the disketera for have a good working? I have problem of I/O SYSTEM: SunOS rches 5.10 Generic_118855-33 i86pc i386 # mount -F pcfs /dev/diskette /diskette mount: I/O error (check) # ps -ef |grep vold # /etc/init.d/volmgt stop # dd if=