Login page. JSP/Servlet

Thread Solved

Join Date: Jan 2006
Posts: 18
Reputation: nisrin is an unknown quantity at this point 
Solved Threads: 0
nisrin nisrin is offline Offline
Newbie Poster

Login page. JSP/Servlet

 
0
  #1
Apr 20th, 2007
im creating a website that deals with the monthly reminders (extracted from Oracle) for my members for a school project. Should I create a login page using JSP or servlets? I am unfamiliar in both the languages.
Will I need to establish my connection for each page if I use JSP instead of servlets?

Im confused, please advice.
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 28
Reputation: saurav is an unknown quantity at this point 
Solved Threads: 2
saurav saurav is offline Offline
Light Poster

Re: Login page. JSP/Servlet

 
0
  #2
Apr 20th, 2007
Hi...you can JSP and Servlets or simple Java Classes as normal easy way.
But i would sugeest you to have it done by using Struts......thats the best way out.
You need require to establish connection each time in any of the above cases.
Just have one Java class which will do that for you and let the other classes call the method of that class.

cheers
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 18
Reputation: nisrin is an unknown quantity at this point 
Solved Threads: 0
nisrin nisrin is offline Offline
Newbie Poster

Re: Login page. JSP/Servlet

 
0
  #3
Apr 20th, 2007
Hello. Thanks for the reply. Programing in Java would have been easier for me. But, Im required to script in either JSP or Servlets.
I suppose I should script in JSP then..How should I retain and extract member details after login, by using sessions??
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 28
Reputation: saurav is an unknown quantity at this point 
Solved Threads: 2
saurav saurav is offline Offline
Light Poster

Re: Login page. JSP/Servlet

 
0
  #4
Apr 20th, 2007
jsp s r actually servlets........they r compiled into servlets........member details u can keep in a db and then do the validation in your java/servlet .....
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 18
Reputation: nisrin is an unknown quantity at this point 
Solved Threads: 0
nisrin nisrin is offline Offline
Newbie Poster

Re: Login page. JSP/Servlet

 
0
  #5
Apr 20th, 2007
I understand jsp codes get compiled into servlets at the backend. But, for the purpose of my project, I would either script in JSP or manually create Servlets..

Member details will be housed in my db. This is what Im not sure about: The login page takes the user's info and see if it exists in the db. After that the next few pages should use the same user info and track down his set reminders. For that information to be retained in the front-end for JSP usage, should I use sessions??

Thank you very much.
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 28
Reputation: saurav is an unknown quantity at this point 
Solved Threads: 2
saurav saurav is offline Offline
Light Poster

Re: Login page. JSP/Servlet

 
0
  #6
Apr 20th, 2007
yes you are right......u have to use sessions.......
retrieve the details wherever u like
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 18
Reputation: nisrin is an unknown quantity at this point 
Solved Threads: 0
nisrin nisrin is offline Offline
Newbie Poster

Re: Login page. JSP/Servlet

 
0
  #7
Apr 20th, 2007
Thank you. Now that the theory is clear, hope I can code well.
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 28
Reputation: saurav is an unknown quantity at this point 
Solved Threads: 2
saurav saurav is offline Offline
Light Poster

Re: Login page. JSP/Servlet

 
0
  #8
Apr 20th, 2007
best of the luck..cheers
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 8
Reputation: kemarS is an unknown quantity at this point 
Solved Threads: 0
kemarS's Avatar
kemarS kemarS is offline Offline
Newbie Poster

Re: Login page. JSP/Servlet

 
0
  #9
Dec 27th, 2007
Hi. I don't mean to be a sponger, but I think his project is similar to mine. I am creating a Movie Theatre site for my Web Apps project. I have almost everything done, but I cant figure out how to create a login page. I was told to try a SELECT query and compare them with the data entered, but that isn't working. Here's the code:
  1. <%@page contentType="text/html"%>
  2. <%@page pageEncoding="UTF-8"%>
  3. <%@ page import="java.sql.*" %>
  4.  
  5.  
  6. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  7. "http://www.w3.org/TR/html4/loose.dtd">
  8.  
  9. <html>
  10. <head>
  11. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  12. <title>JSP Page</title>
  13. </head>
  14. <body>
  15. <%
  16. String url = "jdbc:odbc:userDSN";
  17. String username="";
  18. String password="";
  19. Connection conn=null;
  20. String classPath = "sun.jdbc.odbc.JdbcOdbcDriver";
  21. String usernm = username;
  22. String passwrd = password;
  23.  
  24. try{
  25. Class.forName(classPath);
  26. conn = DriverManager.getConnection(url,username,password);
  27. }catch(Exception exc){
  28. out.println(exc.toString());
  29. }
  30. %>
  31. <%
  32. Statement stm=null;
  33. ResultSet rst=null;
  34.  
  35. stm= conn.createStatement();
  36. String query= "SELECT userID, password FROM user WHERE userID =" +usernm;
  37.  
  38. rst = stm.executeQuery(query);
  39. %>
  40.  
  41. <%= rst.getString("userID") %>
  42. <%= rst.getString("password") %>
  43.  
  44.  
  45.  
  46. <%
  47. if (usernm.equals(userID) && passwrd.equals(password)) { %>
  48.  
  49. <jsp:forward page = "index.jsp"></jsp:forward>
  50.  
  51. <% } else { %>
  52.  
  53. <jsp:forward page = "login_handle.jsp"></jsp:forward>
  54.  
  55.  
  56. <% }
  57. rst.close();
  58. stm.close();
  59. conn.close();
  60. %>
  61. </body>
  62. </html>

When i run it, Tomcat says :
  1. org.apache.jasper.JasperException: Unable to compile class for JSP
  2.  
  3. An error occurred at line: 46 in the jsp file: /login_handle.jsp
  4. Generated servlet error:
  5. C:\Documents and Settings\Kemar\.netbeans\5.5.1\apache-tomcat-5.5.17_base\work\Catalina\localhost\Web_Project\org\apache\jsp\login_005fhandle_jsp.java:94: cannot find symbol
  6. symbol : variable userID
  7. location: class org.apache.jsp.login_005fhandle_jsp
  8. if (usernm.equals(userID) && passwrd.equals(password)) {
  9. ^


I'm not sure where i'm going wrong but i would greatly appreciate your help. I was fortunate enough to stumble across your site. Thanks in advance.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 440
Reputation: Sulley's Boo will become famous soon enough Sulley's Boo will become famous soon enough 
Solved Threads: 10
Sulley's Boo's Avatar
Sulley's Boo Sulley's Boo is offline Offline
Posting Pro in Training

Re: Login page. JSP/Servlet

 
0
  #10
Dec 27th, 2007
Here is an example .. Hope it helps ..

http://www.theserverside.com/discuss...hread_id=41291
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC