0% found this document useful (0 votes)
2 views

Web_Tech_Coding_Assignment

The document contains code examples for a Web Technologies Lab assignment, including a JSP + JDBC snippet for updating student records and a Spring Boot + Hibernate implementation for managing participants. It features a REST controller for CRUD operations and a security configuration for basic authentication. The code demonstrates database connectivity and web security practices in Java applications.

Uploaded by

welogs3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Web_Tech_Coding_Assignment

The document contains code examples for a Web Technologies Lab assignment, including a JSP + JDBC snippet for updating student records and a Spring Boot + Hibernate implementation for managing participants. It features a REST controller for CRUD operations and a security configuration for basic authentication. The code demonstrates database connectivity and web security practices in Java applications.

Uploaded by

welogs3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Web Technologies Lab and UML Assignment

Q1: JSP + JDBC Code

<%@ page import="java.sql.*" %>

<%

String enroll = request.getParameter("enrollment");

String mobile = request.getParameter("mobile");

String newAddress = request.getParameter("address");

String newEmail = request.getParameter("email");

Class.forName("com.mysql.jdbc.Driver");

Connection con = DriverManager.getConnection("jdbc:mysql://localhost/ignou", "root", "password");

PreparedStatement ps = con.prepareStatement("UPDATE students SET address=?, email=? WHERE

enrollment_no=? OR mobile=?");

ps.setString(1, newAddress);

ps.setString(2, newEmail);

ps.setString(3, enroll);

ps.setString(4, mobile);

int i = ps.executeUpdate();

if(i > 0) out.println("Update successful");

else out.println("No record found");

con.close();

%>

Q2: Spring Boot + Hibernate Code

@Entity
Web Technologies Lab and UML Assignment

public class Participant {

@Id @GeneratedValue

private Long id;

private String name;

private String email;

private String phone;

private String paymentStatus;

@RestController

@RequestMapping("/participants")

public class ParticipantController {

@Autowired

private ParticipantRepository repo;

@PostMapping("/register")

public Participant register(@RequestBody Participant p) {

return repo.save(p);

@GetMapping("/")

public List<Participant> getAll() {

return repo.findAll();

@PutMapping("/{id}")
Web Technologies Lab and UML Assignment

public Participant update(@PathVariable Long id, @RequestBody Participant p) {

p.setId(id);

return repo.save(p);

@DeleteMapping("/{id}")

public void delete(@PathVariable Long id) {

repo.deleteById(id);

@Configuration

@EnableWebSecurity

public class SecurityConfig extends WebSecurityConfigurerAdapter {

@Override

protected void configure(HttpSecurity http) throws Exception {

http.csrf().disable()

.authorizeRequests().anyRequest().authenticated()

.and().httpBasic();

@Override

protected void configure(AuthenticationManagerBuilder auth) throws Exception {

auth.inMemoryAuthentication().withUser("admin").password("{noop}admin123").roles("USER");

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy