Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to create a HTML LOV based on a table list (deployment in Tomcat) ?

LauryMay 13 2023

Hi,

When displayed in Tomcat, the following piece of JSP code display a LOV/drop-down list.
How can I get such a LOV in a true HTML-page or block like ?:

<!-- index.html -->
<!DOCTYPE html>
<html>
<head>
<title>This is a title</title>
</head>
<body>
<h1>This is a h1 size text</h1>
[Here should the LOV as a drop-down field be defined with a label/name]
</body>
</html>

JSP code:

<%@ page import="java.sql.*, javax.naming.*, javax.sql.*" %>
<%
Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
DataSource ds = (DataSource) envContext.lookup("jdbc/postgres-14-webs1");
Connection conn = ds.getConnection();
%>
<select name="image_id">
<%
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT id FROM images_resized");
while (rs.next()) {
out.println("<option value=\"" + rs.getString("id") + "\">" + rs.getString("id") + "</option>");
}
rs.close();
stmt.close();
conn.close();
%>
</select>

Kind Regards

Comments

Processing

Post Details

Added on May 13 2023
1 comment
452 views