User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 392,088 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,931 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 8330 | Replies: 11 | Solved
Reply
Join Date: Jan 2006
Posts: 18
Reputation: nisrin is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
nisrin nisrin is offline Offline
Newbie Poster

Login page. JSP/Servlet

  #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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2004
Posts: 28
Reputation: saurav is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 2
saurav saurav is offline Offline
Light Poster

Re: Login page. JSP/Servlet

  #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  
Join Date: Jan 2006
Posts: 18
Reputation: nisrin is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
nisrin nisrin is offline Offline
Newbie Poster

Re: Login page. JSP/Servlet

  #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  
Join Date: Jul 2004
Posts: 28
Reputation: saurav is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 2
saurav saurav is offline Offline
Light Poster

Re: Login page. JSP/Servlet

  #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  
Join Date: Jan 2006
Posts: 18
Reputation: nisrin is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
nisrin nisrin is offline Offline
Newbie Poster

Re: Login page. JSP/Servlet

  #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  
Join Date: Jul 2004
Posts: 28
Reputation: saurav is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 2
saurav saurav is offline Offline
Light Poster

Re: Login page. JSP/Servlet

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

Re: Login page. JSP/Servlet

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

Re: Login page. JSP/Servlet

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

Re: Login page. JSP/Servlet

  #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:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
String url = "jdbc:odbc:userDSN";
String username="";
String password="";
Connection conn=null;
String classPath = "sun.jdbc.odbc.JdbcOdbcDriver";
String usernm = username;
String passwrd = password;
    
try{
    Class.forName(classPath);
    conn = DriverManager.getConnection(url,username,password);
    }catch(Exception exc){
        out.println(exc.toString());
    }
%>
<%
    Statement stm=null;
    ResultSet rst=null;
    
    stm= conn.createStatement();
    String query= "SELECT userID, password FROM user WHERE userID =" +usernm;
    
    rst = stm.executeQuery(query);
%>

<%= rst.getString("userID") %>
<%= rst.getString("password") %>



<% 
if (usernm.equals(userID) && passwrd.equals(password)) { %>

<jsp:forward page = "index.jsp"></jsp:forward>

<% } else { %>

<jsp:forward page = "login_handle.jsp"></jsp:forward>


<% }
            rst.close();
            stm.close();
            conn.close();
%> 
    </body>
</html>

When i run it, Tomcat says :
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 46 in the jsp file: /login_handle.jsp
Generated servlet error:
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
symbol  : variable userID
location: class org.apache.jsp.login_005fhandle_jsp
if (usernm.equals(userID) && passwrd.equals(password)) { 
                  ^


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  
Join Date: Dec 2004
Posts: 406
Reputation: Sulley's Boo will become famous soon enough Sulley's Boo will become famous soon enough 
Rep Power: 5
Solved Threads: 9
Sulley's Boo's Avatar
Sulley's Boo Sulley's Boo is offline Offline
Posting Pro in Training

Re: Login page. JSP/Servlet

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

http://www.theserverside.com/discuss...hread_id=41291
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JSP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JSP Forum

All times are GMT -4. The time now is 12:36 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC