Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Java (JSP) and HTML

  • 15-03-2006 07:48PM
    #1
    Registered Users, Registered Users 2 Posts: 48,709 ✭✭✭✭


    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