[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

05/22/2003 at 11:59PM PDT, ID: 20624104
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

4.6

JSP: Session: Need help trying to use session in JSP

Asked by f11 in Java Server Pages (JSP)

Tags: jsp, request, response, used, session

This is my servlet that authenticates a user and directs him/her to Lyn.jsp. However, if someone types in the URL of the file (e.g. http:localhost.../examples/jsp/Lyn.jp), they can still access the file. This is not that secure. i want to use a session to overcome this folly of mine but i don't know how. This is my servlet (auth.java). Can someone pls take a look and show me how to insert a 'working' session. i thank you for any help that you can provide. cheers!!
------------
auth.java
------------
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.sql.*;

public class auth extends HttpServlet {
      Connection conn;
      PrintWriter out;
    String sqlQuery;
    public void doGet(HttpServletRequest request,
                    HttpServletResponse response)
      throws ServletException, IOException {

    String title = "Wellcome to your e-signON";
    String usrname = request.getParameter("usrname");
    String password = request.getParameter("password");
    HttpSession session = request.getSession(true);

    String usernameQuery = "select username from student where username = '" + usrname + "'";
   
      response.setContentType("text/html");
    out = response.getWriter();  
   
         conn = getConnection(out);
      
    if (conn != null) {
       
     try { // execute the query

      Statement stmt = conn.createStatement();
      ResultSet rst;
            
      rst = stmt.executeQuery(usernameQuery);
   
      // Fetch the query result, and dispaly them in a table
      while (rst.next()) {
                   if(usrname.equals(rst.getString("username"))) {
                        gotoPage("/jsp/Lyn.jsp", request, response);
                       } else {
                        gotoPage("/jsp/Error.jsp",request, response);
                    }
      }
      stmt.close();
     } catch(Exception e) {
            out.println("Cannot fetch data from database!"+e);
     };
    }
    closeConnection(conn, out);
 }
      
  public void doPost(HttpServletRequest request,
                     HttpServletResponse response)
      throws ServletException, IOException {

    doGet(request, response);

  }

  private Connection getConnection(PrintWriter out)
  {
    String driverClassString = "oracle.jdbc.driver.OracleDriver";
    String driverConnectString = "jdbc:oracle:thin:@teach:1521:teach";
    String usrname = "s4001078";
    String pwd = "df991546";  

    Connection conn = null;

    try {
      Class.forName(driverClassString);
      conn = DriverManager.getConnection(driverConnectString, usrname, pwd);
    }
    catch (Exception e) {
      out.println("Cannot close connect to database!"+e);
    }
    return conn;       
  }

  private void closeConnection(Connection conn, PrintWriter out)
  {
    try {
      conn.close();
    }
    catch (Exception e) {
      out.println("Cannot close database connection!");
    }      
  }
        
        public void gotoPage(String webAddress, HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
                  RequestDispatcher dispatcher =
                        getServletContext().getRequestDispatcher(webAddress);
                        dispatcher.forward(request, response);
  }
}

[+][-]05/23/03 12:24 AM, ID: 8569971

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/23/03 01:00 AM, ID: 8570107

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Java Server Pages (JSP)
Tags: jsp, request, response, used, session
Sign Up Now!
Solution Provided By: tbone343
Participating Experts: 2
Solution Grade: A
 
 
[+][-]05/23/03 01:00 AM, ID: 8570110

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/23/03 06:12 PM, ID: 8575656

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/23/03 11:10 PM, ID: 8576337

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/25/03 01:33 AM, ID: 8579579

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/25/03 01:35 AM, ID: 8579584

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/25/03 02:57 AM, ID: 8579684

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/25/03 12:49 PM, ID: 8581059

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/25/03 09:43 PM, ID: 8582331

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/25/03 10:11 PM, ID: 8582395

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/26/03 12:18 AM, ID: 8582733

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/26/03 12:45 AM, ID: 8582844

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/26/03 01:12 AM, ID: 8583033

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/26/03 01:15 AM, ID: 8583053

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/26/03 09:09 AM, ID: 8584937

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/26/03 08:41 PM, ID: 8587400

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/26/03 08:41 PM, ID: 8587402

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/26/03 08:45 PM, ID: 8587412

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/26/03 11:02 PM, ID: 8587861

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/27/03 03:28 AM, ID: 8588983

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/27/03 04:31 AM, ID: 8589431

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/28/03 10:00 PM, ID: 8603424

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/28/03 11:15 PM, ID: 8603665

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/29/03 05:39 PM, ID: 8610294

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/29/03 11:04 PM, ID: 8611616

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/31/03 05:44 PM, ID: 8622168

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/31/03 06:07 PM, ID: 8622232

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20090824-EE-VQP-74