Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Java (JSP) and HTML

Options
  • 15-03-2006 7:48pm
    #1
    Registered Users Posts: 45,906 ✭✭✭✭


    s there a way to enter the following html code in Java: <label for="user">Name:</label><input type="text" name="txtName" default = "name"><br /> where 'name' relating to default refers to a string declared above.

    Here is the full code of the page:

    <html>
    <!-- import statement to include SQL library -->
    <%@ page import="java.sql.*" %>
    <head>
    <title>
    InventoryEditDelete
    </title>
    <link type="text/css" rel="stylesheet" href="style.css"></link>
    </head>
    <jsp:useBean id="InventoryEditDeleteBeanId" scope="session" class="eis.InventoryEditDeleteBean" />
    <jsp:setProperty name="InventoryEditDeleteBeanId" property="*" />
    <body>
    <h1>
    Inventory Edit/Delete Page
    </h1>
    <%

    String InventoryOption = request.getParameter("option");//option is a variable passed from another jsp page.
    String userName="********";
    String password="******";
    String url = "jdbc:oracle:thin:@witnt07.wit.ie:1521:orawit";
    String query = "select item_no,name,description,sale_price,cost_price,tax_rate,category1,sub_category,supplier,expiration_d
    ate,warehouse,storage_location,qty_in_stock,min_stock_level,reorder_level from inventory where name = "+ "'" +InventoryOption + "'";


    try
    {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    }
    catch (ClassNotFoundException e)
    {
    System.err.print("ClassNotFoundException: " + e);
    }

    try
    {
    Connection con = DriverManager.getConnection(url, userName, password);
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery(query);
    //out.println("Item Number | Name | Description | Sale Price | Cost Price | Tax Rate | Category | Sub Category | Supplier Number | Expiration Data | Storage Location | Quantity in Stock | Minimum Stock Level | Reorder Level" + "\n");
    //out.println("<p />");

    while (rs.next())
    {
    String item_num = rs.getString("item_no");
    String name = rs.getString("name");
    String description = rs.getString("description");
    String sale = rs.getString("sale_price");
    String cost = rs.getString("cost_price");
    String tax_rate = rs.getString("tax_rate");
    String category = rs.getString("category1");
    String sub_category = rs.getString("sub_category");
    String supplier = rs.getString("supplier");
    String expiration_date = rs.getString("expiration_date");
    String warehouse = rs.getString("warehouse");
    String storage_location = rs.getString("storage_location");
    String qty_in_stock = rs.getString("qty_in_stock");
    String min_stock_level = rs.getString("min_stock_level");
    String reorder_level = rs.getString("reorder_level");


    out.println(<label for="user">Name:</label><input type="text" name="txtName"><br />); this is where the line is to go.
    out.println("<br />");
    }

    stmt.close();
    con.close();
    }
    catch(SQLException e)
    {
    System.err.println("SQLException: " + e);
    }

    %>


    </body>
    </html>
    _____________________________________

    If it would be easier to to just put the label tags and html code as actual html code i will gladly do it - i just need a way to put a default value, equal a string declared in the "string name - rs.get......" part of the code, into an input field.


Comments

Advertisement