Thursday, 10 April 2025

Write a program to display Actor (actorname, moviename) details by using JSP

 

movie.html

<html>

<head>

    

</head>

<body>

    <h2>Enter Actor Details</h2>

    <form action="movie.jsp" method="post">

        <label for="actorname">Actor Name:</label>

        <input type="text" id="actorname" name="actorname" required><br><br>

        

        <label for="moviename">Movie Name:</label>

        <input type="text" id="moviename" name="moviename" required><br><br>

        

        <input type="submit" value="Display Details">

    </form>

</body>

</html>




movie.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>


<html>


<body>

    

    <%

        String actorName = request.getParameter("actorname");

        String movieName = request.getParameter("moviename");


        if (actorName != null && !actorName.isEmpty() && movieName != null && !movieName.isEmpty()) {

    %>

        <p><strong>Actor Name:</strong> <%= actorName %></p>

        <p><strong>Movie Name:</strong> <%= movieName %></p>

    <%

        } else {

    %>

        <p>Please enter both Actor Name and Movie Name.</p>

    <%

        }

    %>

    <br>

    <a href="movie.html">Go Back</a>

</body>

</html>