<%@ page contentType="text/html; charset=iso-8859-1"%> <%@ page language="java"%> <%@ page errorPage=""%> <%@ page import="java.sql.*"%> <%@ page import="java.io.*"%> <%@ page import="java.util.*"%> <%@ page import="java.lang.*"%> <%@ page session="true"%> Calma Stress Test

Stress at Work Test

The Test involves 6 sections relating to life at work. Please read each statement and click Yes or No, as appropriate. The Test should take you no more than 10 minutes to complete!

<% Connection con = null; Class.forName("com.mysql.jdbc.Driver").newInstance(); con = DriverManager.getConnection("jdbc:mysql://localhost/alexaad1_calmaDB?user=alexaad1_webuser&password=webuser1234"); //con = DriverManager.getConnection("jdbc:mysql://localhost:3306/calmaDB","gavin","whisky"); //Was trying to use this to pass the Connection to StressTestResults.jsp, but didn't work... //session.setAttribute("testAttribute","testValue2"); %>
<% /* Create variables for category, number, category number, question and previous category. Initialise previous category as empty string. Start form and table Query database for category, number and question fields. For every row in the resultSet Initialise category, number and question variables. Compare category with previousCategory If different Create the category number by removing the decimal point and figure from the number variable. Create a table row containing only the category number and name. else Dont Create row containing number and question Create row containing yes and no radio buttons Initialise previousCategory Create submit button End table and form */ String tableName = "stress_test_questions"; String query = null; //the query Statement statement = null; ResultSet resultSet = null; String qNumber, category, question; String catNumber = "0"; String prevCategory = ""; // Query database for category, number and question fields try { statement = con.createStatement(); query = "SELECT * FROM "+ tableName +" "; statement.execute(query); resultSet = statement.getResultSet(); // For every row in the resultSet while (resultSet.next()) { // Initialise category, number and question variables category = resultSet.getString(1); qNumber = resultSet.getString(2); question = resultSet.getString(3); // Print questionnaire subheader row with category number and name if(!category.equals(prevCategory)) { // Create the category number by removing the decimal point and // figure from the number variable catNumber = qNumber.substring(0,(qNumber.length()-2)); // Print row with category number and name out.println(""); out.println(""); out.println(""); out.println(""); // Hidden field for category name, paired with its number out.println(""); } // Print row with the question out.println(""); out.println(""); out.println(""); out.println(""); // Hidden field for category of question out.println(""); // Hidden field to indicate presence of a question, for counting out.println(""); // Print row with yes/no radiobuttons out.println(""); out.println(""); out.println(""); //out.println(""); out.println(""); prevCategory = category; } %>
"); out.println(catNumber); out.println(""); out.println(category); out.println("
"); out.println(qNumber); out.println(""); out.println(question); out.println("
 "); out.println("Yes"); out.println(""); //out.println(""); out.println("No"); out.println(""); out.println("

That's all Folks!

Benchmarking

We would like to pool the responses from all completed questionnaires. This will help us to identify stress-related trends in organisations. You may leave this blank if you wish.

Department/Division:  (Please complete)
Company Name:  (Please complete)
<% out.println(""); out.println("

"); } catch (Exception e) { e.printStackTrace(); out.println("Query failed"); } finally { try { if(con!=null) con.close(); } catch(SQLException sqle) { sqle.printStackTrace(); out.println("con.close() failed"); } } %>
Copyright © 2004 to Calma Partnership LLP   |   Site Map
Site design & construction by