The following list provides some of the Servlet and JSP Practice Questions and their solutions.
- Write a program that displays “Servlet Tutorial – programmingempire.com”.
- Create a servlet that displays the request headers and their values.
- Further, create an HTML form that contains text fields, text area, radio buttons, drop-down list, checkboxes, and date. Also, create two different servlets to display the values entered by the user using the GET and POST methods.
- Create a servlet that displays the servlet config and servlet context parameters. For this purpose, you can create more than one servlet.
- In order to greet the first-time visitors, create a servlet that displays the message “Welcome to the programmingempire.com. You are visiting the first time!”. Subsequently, it should display “Welcome back to the programmingempire.com!”;
- Create a servlet that displays all the cookies in a tabular form, if they exist. Otherwise, display the message “No Cookie on Programmingempire.com”.
- Similarly, create another servlet that displays the number of visits by a user using the session tracking. Also, display the session id and other details of the session object.
- Write a program in JSP that prints the current date and time using JSP expressions.
- The following exercise makes use of both JSP and the servlet. At first, create an HTML form that contains a text field and a submit button. When the user enters a number in the textbox and clicks on the submit button, it invokes a servlet. The servlet finds all prime numbers less that the given number. Further, it inserts all of these prime numbers in an ArrayList. After that, the servlet forwards the control to a JSP page that prints the contents of the JSP page in a tabular form.
- Write a program in JSP that prints n numbers and their factorials in a tabular form. Also, get the value of n from the user using the GET method.
Further Reading
- Angular
- ASP.NET
- C
- C#
- C++
- CSS
- Dot Net Framework
- HTML
- IoT
- Java
- JavaScript
- Kotlin
- PHP
- Power Bi
- Python
- Scratch 3.0
- TypeScript
- VB.NET
