Click here to Skip to main content
15,888,454 members
Home / Discussions / Java
   

Java

 
QuestionDeveloping SaaS in Java Pin
Sarmad Hash8-Jul-13 10:19
Sarmad Hash8-Jul-13 10:19 
AnswerRe: Developing SaaS in Java Pin
Richard MacCutchan8-Jul-13 21:25
mveRichard MacCutchan8-Jul-13 21:25 
GeneralRe: Developing SaaS in Java Pin
Sarmad Hash19-Jul-13 9:28
Sarmad Hash19-Jul-13 9:28 
GeneralRe: Developing SaaS in Java Pin
Richard MacCutchan19-Jul-13 21:54
mveRichard MacCutchan19-Jul-13 21:54 
Questionnew to java - NullPointerException error Pin
Suzy McLain7-Jul-13 12:15
Suzy McLain7-Jul-13 12:15 
AnswerRe: new to java - NullPointerException error Pin
Bernhard Hiller7-Jul-13 20:46
Bernhard Hiller7-Jul-13 20:46 
AnswerRe: new to java - NullPointerException error Pin
mali_angel17-Jul-13 20:11
mali_angel17-Jul-13 20:11 
QuestionLogin process Always false..cannot find the error Pin
mali_angel3-Jul-13 18:16
mali_angel3-Jul-13 18:16 
Im goin to a online bank assignment in java using DAO technigues with mysql.it is not printing an error or exception.but it always jumps to false part.here my code, please tell where I go wrong and how to fix it..

Login.jsp


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>




<title>Insert title here



Login
UserName:
Password:


<%=request.getAttribute("loginMsg") %>






UserServlet.java

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String operation = request.getParameter("operation");
if(operation!=null && operation.equalsIgnoreCase("login")){
loginDetail(request,response);
}else if(operation!=null && operation.equalsIgnoreCase("login")){
logout(request,response);
}
}



private void loginDetail(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
User u = new User();
UserService us =new UserServiceImpl() ;

String Uname = request.getParameter("txtUname");
String Pwrd = request.getParameter("txtPwrd");

u.setUname(Uname);
u.setPwrd(Pwrd);

System.out.println(Uname+""+Pwrd);
try {
if(us.Userlogin(u.getUname(),u.getPwrd())){
String message = "Thank you, " + Uname +"..You are now logged into the system";
HttpSession session = request.getSession(true);
session.setAttribute("username", Uname);
session.setAttribute("password", Pwrd);
response.setContentType("text/html");
request.setAttribute("message", message);
request.getRequestDispatcher("/Menu.jsp").forward(request, response);
}else {
String message = "You have to register first or check Your user name password again!";
request.setAttribute("loginMsg", message);
RequestDispatcher rd = getServletContext().getRequestDispatcher("/Login.jsp");
rd.forward(request, response);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}


UserServiceImpl.java


@Override
public boolean Userlogin(String Uname, String Pwrd) {
// TODO Auto-generated method stub
boolean result=false;
UserDAO udoi = new UserDAOImpl();
User user = new User();
System.out.println("ppp");
user.setUname(Uname);
user.setPwrd(Pwrd);
System.out.println("//////");
System.out.println(user.getUname()+user.getPwrd());
if(user!=null){
System.out.println(user.getUname()+user.getPwrd());
result = udoi.getLoginDetail(Uname, Pwrd);
//result=true;
}
return result;
}


UserDAOImpl.java


@Override
public boolean getLoginDetail(String Uname, String Pwrd) {
// TODO Auto-generated method stub
System.out.println(Uname+"++"+Pwrd);
Connection conn=null;
ResultSet rs=null;
boolean SUCCESS=false;
try {
conn=getConnection();
//String sql="SELECT * FROM login WHERE UserName='amal' and password='secret' ";
String sql="SELECT * FROM login WHERE UserName='" + Uname + "' and Password='"+ Pwrd + "' ";
System.out.println(sql);
Statement stmt=conn.createStatement();
rs = stmt.executeQuery(sql);
System.out.println("ddddddddddddddddd" + rs==null);
System.out.println("sssssssssssssssss" + rs.next());
while(rs.next()) {
System.out.println(Uname+"*_*"+Pwrd);
String uname=rs.getString("UserName");
String password=rs.getString("Password");
System.out.println(Uname+"***"+Pwrd);
if ((uname.equals(Uname)) && (password.equals(Pwrd))){
SUCCESS=true;
}else {
SUCCESS=false;
}

}
}
catch (Exception e){
e.printStackTrace();
}finally {
try {
conn.close();
rs.close();
} catch (SQLException ex) {
Logger.getLogger(AccountDAOImpl.class.getName()).log(Level.SEVERE, null, ex);
}
}
return SUCCESS;
}

private Connection getConnection() {
// TODO Auto-generated method stub
ConnectionFactory cf = new ConnectionFactory();
Connection conn = null;
try {
conn = cf.getConnection();
} catch (SQLException ex) {
Logger.getLogger(AccountDAOImpl.class.getName()).log(Level.SEVERE, null, ex);
}
return conn;
}


EveryImpl file has it's interfaceclass.please tell me where I go wrong. Thank you!
AnswerRe: Login process Always false..cannot find the error Pin
Shubhashish_Mandal3-Jul-13 19:53
professionalShubhashish_Mandal3-Jul-13 19:53 
QuestionLogin process Always false..cannot find the error Pin
mali_angel3-Jul-13 17:22
mali_angel3-Jul-13 17:22 
AnswerRe: Login process Always false..cannot find the error Pin
mali_angel3-Jul-13 17:28
mali_angel3-Jul-13 17:28 
AnswerRe: Login process Always false..cannot find the error Pin
Shubhashish_Mandal3-Jul-13 19:40
professionalShubhashish_Mandal3-Jul-13 19:40 
GeneralRe: Login process Always false..cannot find the error Pin
mali_angel3-Jul-13 19:51
mali_angel3-Jul-13 19:51 
GeneralRe: Login process Always false..cannot find the error Pin
Shubhashish_Mandal3-Jul-13 19:54
professionalShubhashish_Mandal3-Jul-13 19:54 
QuestionactionPerformed in another class Pin
chdboy1-Jul-13 19:27
chdboy1-Jul-13 19:27 
SuggestionRe: actionPerformed in another class Pin
Richard MacCutchan1-Jul-13 20:46
mveRichard MacCutchan1-Jul-13 20:46 
AnswerRe: actionPerformed in another class Pin
Shubhashish_Mandal3-Jul-13 19:48
professionalShubhashish_Mandal3-Jul-13 19:48 
Questionwhy java in linux has outstanding performance even jvm slow it down? Pin
crunchor28-Jun-13 17:55
crunchor28-Jun-13 17:55 
AnswerRe: why java in linux has outstanding performance even jvm slow it down? Pin
Richard MacCutchan28-Jun-13 23:19
mveRichard MacCutchan28-Jun-13 23:19 
GeneralRe: why java in linux has outstanding performance even jvm slow it down? Pin
crunchor28-Jun-13 23:22
crunchor28-Jun-13 23:22 
AnswerRe: why java in linux has outstanding performance even jvm slow it down? Pin
NotPolitcallyCorrect29-Jun-13 0:51
NotPolitcallyCorrect29-Jun-13 0:51 
QuestionMessage Closed Pin
27-Jun-13 17:11
crunchor27-Jun-13 17:11 
AnswerRe: official "forum" in oracle really screw up Pin
Richard MacCutchan27-Jun-13 21:23
mveRichard MacCutchan27-Jun-13 21:23 
GeneralRe: official "forum" in oracle really screw up Pin
crunchor27-Jun-13 21:40
crunchor27-Jun-13 21:40 
GeneralRe: official "forum" in oracle really screw up Pin
Richard MacCutchan27-Jun-13 22:33
mveRichard MacCutchan27-Jun-13 22:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.