Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Glassfish and JSP

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Location
    Durban
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Glassfish and JSP

    Good day java People

    I am attempting to build a jsp page that connects to a MS SQL 2008 database and retrieves information and displays it on the web page however when i run my jsp script it seems only the html part gets executed and reflected on the output(the web page) the java code seems not to be executing, im thinking mayb glassfish does not support JSP or there is something wrong with my code. Please see below what i have done to set up this project

    1)Downloaded and set up appopriate driver for MS SQL server connection in Netbeans (used 'net.sourceforge.jtds.jdbc.Driver')
    2)Setup Glassfish Server 4 as my web server in netbeans
    3)connection between application and database established successfully.

    Please see code below and attached please find the what the output looks like after running the below code


    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <%@page import="java.sql.*;"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Mr price Summary</title>
    </head>
    <body bgcolor="teal">
    <center>
    <h1>This is the Mr Price Summary</h1>

     
            <% 
                String user = "sa";
                String pass = "p@ssword123";
                String data = "jdbc:jtds:sqlserver://localhost:1433;databaseName=SolarWindsOrion";
             System.setProperty("jdbc.drivers","net.sourceforge.jtds.jdbc.Driver");
     
     
             try {
               Class.forName("net.sourceforge.jtds.jdbc.Driver");
     
                    Connection conn = DriverManager.getConnection(
                    data,user,pass);
     
                Statement state = conn.createStatement();
     
     
                ResultSet resultset = 
                    state.executeQuery("SELECT a.Caption, a.IP_Address, b.Model, b.ServiceTag, a.PONumber FROM Nodes a JOIN APM_HardwareInfo b ON a.NodeID = b.NodeID WHERE Department = 'mrprice'"); 
     
                while(resultset.next()){
     
            %>

    <table border="1" >
    <tr>
    <th>Device Name</th>
    <th>IP Address</th>
    <th>Model</th>
    <th>Serial Number</th>
    <th>Region</th>
    </tr>
    <tr>
    <td><%=resultset.getString("a.Caption")%></td>
    <td><%=resultset.getString("a.IP_Address")%></td>
    <td><%=resultset.getString("b.Model")%></td>
    <td><%=resultset.getString("b.ServiceTag")%></td>
    <td><%=resultset.getString("b.PONumber")%></td>
    </tr>
    </table>


                   <%
     
     
     
        }
             state.close();
     
        }catch (SQLException e) {
            System.out.println(e.toString());
        }catch (ClassNotFoundException e) {
            System.out.println(e.toString());
        }    
          %>

    </center>
    </body>
    </html>
    Attached Images Attached Images


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Glassfish and JSP

    Thread moved.

  3. #3
    Junior Member
    Join Date
    Oct 2013
    Location
    Durban
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Glassfish and JSP

    Thread Moved? what does that mean

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Glassfish and JSP

    Thread moved = the thread was moved from one subforum to another (and you got a bump out of it, now 3)

Similar Threads

  1. GlassFish Error : No suitable driver found
    By HK027 in forum JDBC & Databases
    Replies: 1
    Last Post: July 2nd, 2014, 05:32 AM
  2. EAR working on Glassfish v2 but not on V3
    By kai555 in forum Web Frameworks
    Replies: 0
    Last Post: February 13th, 2013, 10:06 AM
  3. glassfish error - process already using port 4848
    By wdh in forum Web Frameworks
    Replies: 8
    Last Post: November 13th, 2012, 04:51 AM
  4. Database Connect Error on Eclipse ( JAVAEE/Glassfish)
    By thisbeme in forum JDBC & Databases
    Replies: 0
    Last Post: March 6th, 2012, 07:27 AM
  5. Sometimes users see other's secure data over ssl on jsp struts and glassfish
    By amirali1982 in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: December 30th, 2010, 05:40 AM

Tags for this Thread