You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.1 KiB
34 lines
1.1 KiB
// DataQueryServlet.java
|
|
// SingleThreadModel servlet that will create and maintain database connections.
|
|
// The database connection parameters are read from a properties file. The servlet
|
|
// formulates queries based on the its request parameters and session properties.
|
|
|
|
package com.bullseyecomputing.servlets;
|
|
|
|
import java.io.*;
|
|
import java.util.*;
|
|
import java.sql.*;
|
|
import javax.servlet.*;
|
|
import javax.servlet.http.*;
|
|
|
|
public class DataQueryServlet extends HttpServlet implements SingleThreadModel {
|
|
|
|
// Initialization code
|
|
Connection conn = null;
|
|
|
|
public void init(ServletConfig config) throws ServletException {
|
|
super.init(config)
|
|
loadConnectionParameters();
|
|
conn = createConnection();
|
|
conn.setAutoCommit(false);
|
|
}
|
|
|
|
// HTTP GET handler
|
|
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
|
throws ServletException, IOException {
|
|
|
|
// Check for existing session
|
|
HttpSession session = request.getSession(false);
|
|
String user = session.getAttribute("j_username");
|
|
|
|
// Get query parameters from the request args
|