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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Java (JSP) and HTML

  • 15-03-2006 6:48pm
    #1
    Registered Users, Registered Users 2 Posts: 46,829 ✭✭✭✭


    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