unit 3 (1)
unit 3 (1)
Here are simple solutions to your requests, written in Java with basic
functionality:
### (i) Java Servlet to Display Net Salary of Employee using JDBC
```sql
name VARCHAR(50),
basic_salary DECIMAL(10,2),
hra DECIMAL(10,2),
other_allowances DECIMAL(10,2)
);
```
```java
@WebServlet("/EmployeeSalary")
stmt.setInt(1, empId);
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
response.setContentType("text/html");
} else {
} catch (Exception e) {
e.printStackTrace();
```
3) ### (i) Servlet to Display Waiting List Status of Train (using PNR)
```sql
status VARCHAR(50)
);
```
```java
@WebServlet("/TrainStatus")
stmt.setString(1, pnr);
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
response.setContentType("text/html");
} else {
} catch (Exception e) {
e.printStackTrace();
```
```java
@WebServlet("/CookieExample")
if (cookies != null) {
if ("user".equals(cookie.getName())) {
cookieFound = true;
break;
if (!cookieFound) {
response.addCookie(newCookie);
```
### Summary:
2. **Train Status Servlet**: Fetches the train status from the database
using a PNR number.
These are simple and short examples for your 16-mark answer.