Spring MVC – Hidden

Spring MVC – Hidden Field Example ”; Previous Next The following example describes how to use a Hidden Field in forms using the Spring Web MVC framework. To start with, let us have a working Eclipse IDE in place and consider the following steps to develop a Dynamic Form based Web Application using Spring Web Framework. Step Description 1 Create a project with a name HelloWeb under a package com.tutorialspoint as explained in the Spring MVC – Hello World chapter. 2 Create Java classes Student, StudentController under the com.tutorialspoint package. 3 Create view files student.jsp, result.jsp under the jsp sub-folder. 4 The final step is to create the content of the source and configuration files and export the application as explained below. Student.java package com.tutorialspoint; public class Student { private Integer age; private String name; private Integer id; public void setAge(Integer age) { this.age = age; } public Integer getAge() { return age; } public void setName(String name) { this.name = name; } public String getName() { return name; } public void setId(Integer id) { this.id = id; } public Integer getId() { return id; } } StudentController.java package com.tutorialspoint; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; import org.springframework.ui.ModelMap; @Controller public class StudentController { @RequestMapping(value = “/student”, method = RequestMethod.GET) public ModelAndView student() { return new ModelAndView(“student”, “command”, new Student()); } @RequestMapping(value = “/addStudent”, method = RequestMethod.POST) public String addStudent(@ModelAttribute(“SpringWeb”)Student student, ModelMap model) { model.addAttribute(“name”, student.getName()); model.addAttribute(“age”, student.getAge()); model.addAttribute(“id”, student.getId()); return “result”; } } Here, for the first service method student(), we have passed a blank Studentobject in the ModelAndView object with the name “command”, because the spring framework expects an object with the name “command”, if you are using <form:form> tags in your JSP file. So, when the student() method is called, it returns the student.jsp view. The second service method addStudent() will be called against a POST method on the HelloWeb/addStudent URL. You will prepare your model object based on the submitted information. Finally, a “result” view will be returned from the service method, which will result in rendering result.jsp student.jsp <%@taglib uri = “http://www.springframework.org/tags/form” prefix = “form”%> <html> <head> <title>Spring MVC Form Handling</title> </head> <body> <h2>Student Information</h2> <form:form method = “POST” action = “/HelloWeb/addStudent”> <table> <tr> <td><form:label path = “name”>Name</form:label></td> <td><form:input path = “name” /></td> </tr> <tr> <td><form:label path = “age”>Age</form:label></td> <td><form:input path = “age” /></td> </tr> <tr> <td>< </td> <td><form:hidden path = “id” value = “1” /></td> </tr> <tr> <td colspan = “2”> <input type = “submit” value = “Submit”/> </td> </tr> </table> </form:form> </body> </html> Here, we are using the <form:hidden /> tag to render a HTML hidden field. For example − <form:hidden path = “id” value = “1”/> It will render following HTML content. <input id = “id” name = “id” type = “hidden” value = “1”/> result.jsp <%@taglib uri = “http://www.springframework.org/tags/form” prefix = “form”%> <html> <head> <title>Spring MVC Form Handling</title> </head> <body> <h2>Submitted Student Information</h2> <table> <tr> <td>Name</td> <td>${name}</td> </tr> <tr> <td>Age</td> <td>${age}</td> </tr> <tr> <td>ID</td> <td>${id}</td> </tr> </table> </body> </html> Once you are done with creating source and configuration files, export your application. Right click on your application and use Export → WAR File option and save your HelloWeb.war file in Tomcat”s webapps folder. Now start your Tomcat server and make sure you are able to access other webpages from webapps folder using a standard browser. Try a URL – http://localhost:8080/HelloWeb/student and we will see the following screen, if everything is fine with the Spring Web Application. After submitting the required information, click on the submit button to submit the form. We will see the following screen, if everything is fine with your Spring Web Application. Print Page Previous Next Advertisements ”;

Spring Security – Basic Authentication

Spring Security – Basic Authentication ”; Previous Next We”ve seen form based login so far where an html based form is used for Username/password authentication. We can either create our own custom login form or use spring security provided default login form. There is another way to ask username/password where we can ask user to pass username/password in the url itself using basic authentication. In case of Web browse, whenever a user requests a protected resource, Spring Security checks for the authentication of the request. If the request is not authenticated/authorized, the user will be asked for username/password using default dialog as shown below: Spring Security provides following configuration to achieve basic authentication − protected void configure(HttpSecurity http) throws Exception { http // … .authorizeHttpRequests(request -> request.anyRequest().authenticated()) .httpBasic(Customizer.withDefaults()) .build(); } Here we”re configuring spring security for every request to be authenticated using basic authentication mechanism. Let us start actual programming with Spring Security. Before you start writing your first example using Spring framework, you have to make sure that you have set up your Spring environment properly as explained in Spring Security – Environment Setup Chapter. We also assume that you have a bit of working knowledge on Spring Tool Suite IDE. Now let us proceed to write a Spring MVC based Application managed by Maven, which will ask user to login, authenticate user and then provide option to logout using Spring Security Form Login Feature. Create Project using Spring Initializr Spring Initializr is great way to start with Spring Boot project. It provides a easy to use User Interface to create a project, add dependencies, select java runtime etc. It generates a skeleton project structure which once downloaded can be imported in spring tool suite and we can proceed with our readymade project structure. We”re choosing a maven project, naming the project as formlogin, with java version as 21. Following dependencies are added: Spring Web Spring Security Thymeleaf Spring Boot DevTools Thymeleaf is a templating engine for Java. It allows us to quickly develop static or dynamic web pages for rendering in the browser. It is extremely extensible and allows us to define and customize the processing of our templates in fine detail. In addition to this, we can learn more about Thymeleaf by clicking this link. Let”s move on to generate our project and download it. We then extract it to a folder of our choice and use any IDE to open it. I shall be using Spring Tools Suite 4. It is available for free downloading from the https://spring.io/tools website and is optimized for spring applications. pom.xml with all relevant dependencies Let”s take a look at our pom.xml file. It should look something similar to this − pom.xml <?xml version=”1.0″ encoding=”UTF-8″?> <project xmlns=”http://maven.apache.org/POM/4.0.0″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd”> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>3.3.1</version> <relativePath/> <!– lookup parent from repository –> </parent> <groupId>com.tutorialspoint.security</groupId> <artifactId>formlogin</artifactId> <version>0.0.1-SNAPSHOT</version> <name>formlogin</name> <description>Demo project for Spring Boot</description> <url/> <licenses> <license/> </licenses> <developers> <developer/> </developers> <scm> <connection/> <developerConnection/> <tag/> <url/> </scm> <properties> <java.version>21</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.thymeleaf.extras</groupId> <artifactId>thymeleaf-extras-springsecurity6</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-test</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project> Spring Security Configuration Class Inside of our config package, we have created the WebSecurityConfig class. We shall be using this class for our security configurations, so let”s annotate it with an @Configuration annotation and @EnableWebSecurity. As a result, Spring Security knows to treat this class a configuration class. As we can see, configuring applications have been made very easy by Spring. WebSecurityConfig package com.tutorialspoint.security.formlogin.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.Customizer; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.core.userdetails.User; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.provisioning.InMemoryUserDetailsManager; import org.springframework.security.web.SecurityFilterChain; @Configuration @EnableWebSecurity public class WebSecurityConfig { @Bean protected UserDetailsService userDetailsService() { UserDetails user = User.builder() .username(“user”) .password(passwordEncoder().encode(“user123”)) .roles(“USER”) .build(); UserDetails admin = User.builder() .username(“admin”) .password(passwordEncoder().encode(“admin123”)) .roles(“USER”, “ADMIN”) .build(); return new InMemoryUserDetailsManager(user, admin); } @Bean protected PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); } @Bean protected SecurityFilterChain filterChain(HttpSecurity http) throws Exception { return http .csrf(AbstractHttpConfigurer::disable) .authorizeHttpRequests(request -> request.anyRequest().authenticated()) .httpBasic(Customizer.withDefaults()) .build(); } } Configuration Class Details Let”s take a look at our configuration class. First, we shall create a bean of our UserDetailsService class by using the userDetailsService() method. We shall be using this bean for managing our users for this application. Here, to keep things simple, we shall use an InMemoryUserDetailsManager instance to create users. These users, along with our given username and password, are mapped to User and Admin roles respectively. Password Encoder Now, let”s look at our PasswordEncoder. We shall be using a BCryptPasswordEncoder instance for this example. Hence, while creating the user, we used the passwordEncoder to encode our plaintext password like this: .password(passwordEncoder().encode(“user123″)) Http Security Configuration After the above steps, we move on to our next configuration. Here, we”ve defined the filterChain method. This method takes HttpSecurity as a parameter. We shall be configuring this to use our form login and logout function. We can observe that all these functionalities are available in Spring Security. Let’s study the below section in detail − http .csrf(AbstractHttpConfigurer::disable) .authorizeHttpRequests(request -> request.anyRequest().authenticated()) .httpBasic(Customizer.withDefaults()) .build(); There are a few points to note here − We have disabled csrf or Cross-Site Request Forgery protection As this is a simple application only for demonstration purposes, we can safely disable this for now. Then we add configuration which requires all requests to be authenticated. After that, we”re using httpBasic() functionality of Spring Security as mentioned above. This makes browser to ask for username/password. In case of rest API, we”can set authetication as Basic Auth as we shall see later in this section. Controller Class In this class, we”ve created a mapping for single “/” endpoint for the index page of this application, for simplicity. This will redirect to index.html. AuthController package com.tutorialspoint.security.formlogin.controllers; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; @Controller public class AuthController { @GetMapping(“/”) public String home() { return “index”; } } Views Create

Spring Boot CLI – Useful Resources

Spring Boot CLI – Useful Resources ”; Previous Next The following resources contain additional information on Spring Boot CLI. Please use them to get more in-depth knowledge on this topic. Useful Links on Spring Boot CLI Spring Boot CLI – Spring Boot CLI Official Home page. Useful Books on Spring Boot CLI To enlist your site on this page, please drop an email to [email protected] Print Page Previous Next Advertisements ”;

Spring Boot CLI – Default Statements

Spring Boot CLI – Default Statements ”; Previous Next Default Imports Spring CLI automatically imports many libraries by default so that explicit imports are not required. Consider the following groovy script. @RestController class FirstApplication { @RequestMapping(“/”) String welcome() { “Welcome to TutorialsPoint.Com” } } Here import for @RestController, @RequestMapping annotations are already included by default by Spring Boot. We”re not even require to use fully-qualified names. You can check by running the application. Type the following command E:/Test/> spring run FirstApplication.groovy You can see the following output on console. . ____ _ __ _ _ /\ / ___”_ __ _ _(_)_ __ __ _ ( ( )___ | ”_ | ”_| | ”_ / _` | \/ ___)| |_)| | | | | || (_| | ) ) ) ) ” |____| .__|_| |_|_| |___, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.6.3) 2022-02-03 11:29:01.177 INFO 10668 — [ runner-0] o.s.boot.SpringApplication : Starting application using Java 11.0.11 on DESKTOP-86KD9FC with PID 10668 (started by intel in F:Test) 2022-02-03 11:29:01.187 INFO 10668 — [ runner-0] o.s.boot.SpringApplication : No active profile set, falling back to default profiles: default 2022-02-03 11:29:03.555 INFO 10668 — [ runner-0] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2022-02-03 11:29:03.591 INFO 10668 — [ runner-0] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2022-02-03 11:29:03.592 INFO 10668 — [ runner-0] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.56] 2022-02-03 11:29:03.659 INFO 10668 — [ runner-0] org.apache.catalina.loader.WebappLoader : Unknown class loader [org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader@8646db9] of class [class org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader] 2022-02-03 11:29:03.735 INFO 10668 — [ runner-0] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2022-02-03 11:29:03.736 INFO 10668 — [ runner-0] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2107 ms 2022-02-03 11:29:04.945 INFO 10668 — [ runner-0] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ”” 2022-02-03 11:29:04.968 INFO 10668 — [ runner-0] o.s.boot.SpringApplication : Started application in 4.811 seconds (JVM running for 8.805) Automatic Main Method We are not required to create standard main method for groovy script to initialize a spring application. It is automatically created for spring boot application. Print Page Previous Next Advertisements ”;

Spring Boot CLI – “grab” Co-Ordination Deduction

“grab” Co-ordinates Deduction ”; Previous Next We can specify a dependency using @Grab annotation even without specifying group or version. For example, @Grab(”antlr”) Now Spring Boot CLI will download 2.7.7 version of antlr as it is present in Spring Boot”s default dependency metadata for 2.6.3 version. Spring Boot maintains all dependency versions by default which are provided in its CLI, Maven dependency management and Gradle plugin. Whenever we declare a dependency of any of those artifacts present in efault dependency metadata without declaring a version, the version listed in its table will be used. Following table shows all the dependencies and their versions included in the default metadata for Spring Boot CLI 2.6.3 version. Group Id Artifact Id Version antlr antlr 2.7.7 ch.qos.logback logback-access 1.2.10 ch.qos.logback logback-classic 1.2.10 ch.qos.logback logback-core 1.2.10 com.atomikos transactions-jdbc 4.0.6 com.atomikos transactions-jms 4.0.6 com.atomikos transactions-jta 4.0.6 com.couchbase.client java-client 3.2.4 com.datastax.oss java-driver-core 4.13.0 com.datastax.oss java-driver-core-shaded 4.13.0 com.datastax.oss java-driver-mapper-processor 4.13.0 com.datastax.oss java-driver-mapper-runtime 4.13.0 com.datastax.oss java-driver-metrics-micrometer 4.13.0 com.datastax.oss java-driver-metrics-microprofile 4.13.0 com.datastax.oss java-driver-query-builder 4.13.0 com.datastax.oss java-driver-shaded-guava 25.1-jre-graal-sub-1 com.datastax.oss java-driver-test-infra 4.13.0 com.datastax.oss native-protocol 1.5.0 com.fasterxml classmate 1.5.1 com.fasterxml.jackson.core jackson-annotations 2.13.1 com.fasterxml.jackson.core jackson-core 2.13.1 com.fasterxml.jackson.core jackson-databind 2.13.1 com.fasterxml.jackson.dataformat jackson-dataformat-avro 2.13.1 com.fasterxml.jackson.dataformat jackson-dataformat-cbor 2.13.1 com.fasterxml.jackson.dataformat jackson-dataformat-csv 2.13.1 com.fasterxml.jackson.dataformat jackson-dataformat-ion 2.13.1 com.fasterxml.jackson.dataformat jackson-dataformat-properties 2.13.1 com.fasterxml.jackson.dataformat jackson-dataformat-protobuf 2.13.1 com.fasterxml.jackson.dataformat jackson-dataformat-smile 2.13.1 com.fasterxml.jackson.dataformat jackson-dataformat-toml 2.13.1 com.fasterxml.jackson.dataformat jackson-dataformat-xml 2.13.1 com.fasterxml.jackson.dataformat jackson-dataformat-yaml 2.13.1 com.fasterxml.jackson.datatype jackson-datatype-eclipse-collections 2.13.1 com.fasterxml.jackson.datatype jackson-datatype-guava 2.13.1 com.fasterxml.jackson.datatype jackson-datatype-hibernate4 2.13.1 com.fasterxml.jackson.datatype jackson-datatype-hibernate5 2.13.1 com.fasterxml.jackson.datatype jackson-datatype-hibernate5-jakarta 2.13.1 com.fasterxml.jackson.datatype jackson-datatype-hppc 2.13.1 com.fasterxml.jackson.datatype jackson-datatype-jakarta-jsonp 2.13.1 com.fasterxml.jackson.datatype jackson-datatype-jaxrs 2.13.1 com.fasterxml.jackson.datatype jackson-datatype-jdk8 2.13.1 com.fasterxml.jackson.datatype jackson-datatype-joda 2.13.1 com.fasterxml.jackson.datatype jackson-datatype-joda-money 2.13.1 com.fasterxml.jackson.datatype jackson-datatype-json-org 2.13.1 com.fasterxml.jackson.datatype jackson-datatype-jsr310 2.13.1 com.fasterxml.jackson.datatype jackson-datatype-jsr353 2.13.1 com.fasterxml.jackson.datatype jackson-datatype-pcollections 2.13.1 com.fasterxml.jackson.jakarta.rs jackson-jakarta-rs-base 2.13.1 com.fasterxml.jackson.jakarta.rs jackson-jakarta-rs-cbor-provider 2.13.1 com.fasterxml.jackson.jakarta.rs jackson-jakarta-rs-json-provider 2.13.1 com.fasterxml.jackson.jakarta.rs jackson-jakarta-rs-smile-provider 2.13.1 com.fasterxml.jackson.jakarta.rs jackson-jakarta-rs-xml-provider 2.13.1 com.fasterxml.jackson.jakarta.rs jackson-jakarta-rs-yaml-provider 2.13.1 com.fasterxml.jackson.jaxrs jackson-jaxrs-base 2.13.1 com.fasterxml.jackson.jaxrs jackson-jaxrs-cbor-provider 2.13.1 com.fasterxml.jackson.jaxrs jackson-jaxrs-json-provider 2.13.1 com.fasterxml.jackson.jaxrs jackson-jaxrs-smile-provider 2.13.1 com.fasterxml.jackson.jaxrs jackson-jaxrs-xml-provider 2.13.1 com.fasterxml.jackson.jaxrs jackson-jaxrs-yaml-provider 2.13.1 com.fasterxml.jackson.jr jackson-jr-all 2.13.1 com.fasterxml.jackson.jr jackson-jr-annotation-support 2.13.1 com.fasterxml.jackson.jr jackson-jr-objects 2.13.1 com.fasterxml.jackson.jr jackson-jr-retrofit2 2.13.1 com.fasterxml.jackson.jr jackson-jr-stree 2.13.1 com.fasterxml.jackson.module jackson-module-afterburner 2.13.1 com.fasterxml.jackson.module jackson-module-blackbird 2.13.1 com.fasterxml.jackson.module jackson-module-guice 2.13.1 com.fasterxml.jackson.module jackson-module-jakarta-xmlbind-annotations 2.13.1 com.fasterxml.jackson.module jackson-module-jaxb-annotations 2.13.1 com.fasterxml.jackson.module jackson-module-jsonSchema 2.13.1 com.fasterxml.jackson.module jackson-module-kotlin 2.13.1 com.fasterxml.jackson.module jackson-module-mrbean 2.13.1 com.fasterxml.jackson.module jackson-module-no-ctor-deser 2.13.1 com.fasterxml.jackson.module jackson-module-osgi 2.13.1 com.fasterxml.jackson.module jackson-module-parameter-names 2.13.1 com.fasterxml.jackson.module jackson-module-paranamer 2.13.1 com.fasterxml.jackson.module jackson-module-scala_2.11 2.13.1 com.fasterxml.jackson.module jackson-module-scala_2.12 2.13.1 com.fasterxml.jackson.module jackson-module-scala_2.13 2.13.1 com.fasterxml.jackson.module jackson-module-scala_3 2.13.1 com.github.ben-manes.caffeine caffeine 2.9.3 com.github.ben-manes.caffeine guava 2.9.3 com.github.ben-manes.caffeine jcache 2.9.3 com.github.ben-manes.caffeine simulator 2.9.3 com.github.mxab.thymeleaf.extras thymeleaf-extras-data-attribute 2.0.1 com.google.appengine appengine-api-1.0-sdk 1.9.93 com.google.cloud cloud-spanner-r2dbc 1.1.0 com.google.code.gson gson 2.8.9 com.h2database h2 1.4.200 com.hazelcast hazelcast 4.2.4 com.hazelcast hazelcast-hibernate52 2.2.1 com.hazelcast hazelcast-hibernate53 2.2.1 com.hazelcast hazelcast-spring 4.2.4 com.ibm.db2 jcc 11.5.7.0 com.jayway.jsonpath json-path 2.6.0 com.jayway.jsonpath json-path-assert 2.6.0 com.microsoft.sqlserver mssql-jdbc 9.4.1.jre8 com.oracle.database.ha ons 21.3.0.0 com.oracle.database.ha simplefan 21.3.0.0 com.oracle.database.jdbc ojdbc11 21.3.0.0 com.oracle.database.jdbc ojdbc11-production 21.3.0.0 com.oracle.database.jdbc ojdbc8 21.3.0.0 com.oracle.database.jdbc ojdbc8-production 21.3.0.0 com.oracle.database.jdbc rsi 21.3.0.0 com.oracle.database.jdbc ucp 21.3.0.0 com.oracle.database.jdbc ucp11 21.3.0.0 com.oracle.database.jdbc.debug ojdbc11-debug 21.3.0.0 com.oracle.database.jdbc.debug ojdbc11-observability-debug 21.3.0.0 com.oracle.database.jdbc.debug ojdbc11_g 21.3.0.0 com.oracle.database.jdbc.debug ojdbc11dms_g 21.3.0.0 com.oracle.database.jdbc.debug ojdbc8-debug 21.3.0.0 com.oracle.database.jdbc.debug ojdbc8-observability-debug 21.3.0.0 com.oracle.database.jdbc.debug ojdbc8_g 21.3.0.0 com.oracle.database.jdbc.debug ojdbc8dms_g 21.3.0.0 com.oracle.database.nls orai18n 21.3.0.0 com.oracle.database.observability dms 21.3.0.0 com.oracle.database.observability ojdbc11-observability 21.3.0.0 com.oracle.database.observability ojdbc11dms 21.3.0.0 com.oracle.database.observability ojdbc8-observability 21.3.0.0 com.oracle.database.observability ojdbc8dms 21.3.0.0 com.oracle.database.r2dbc oracle-r2dbc 0.1.0 com.oracle.database.security oraclepki 21.3.0.0 com.oracle.database.security osdt_cert 21.3.0.0 com.oracle.database.security osdt_core 21.3.0.0 com.oracle.database.xml xdb 21.3.0.0 com.oracle.database.xml xmlparserv2 21.3.0.0 com.querydsl querydsl-apt 5.0.0 com.querydsl querydsl-codegen 5.0.0 com.querydsl querydsl-codegen-utils 5.0.0 com.querydsl querydsl-collections 5.0.0 com.querydsl querydsl-core 5.0.0 com.querydsl querydsl-guava 5.0.0 com.querydsl querydsl-hibernate-search 5.0.0 com.querydsl querydsl-jdo 5.0.0 com.querydsl querydsl-jpa 5.0.0 com.querydsl querydsl-jpa-codegen 5.0.0 com.querydsl querydsl-kotlin 5.0.0 com.querydsl querydsl-kotlin-codegen 5.0.0 com.querydsl querydsl-lucene3 5.0.0 com.querydsl querydsl-lucene4 5.0.0 com.querydsl querydsl-lucene5 5.0.0 com.querydsl querydsl-mongodb 5.0.0 com.querydsl querydsl-scala 5.0.0 com.querydsl querydsl-spatial 5.0.0 com.querydsl querydsl-sql 5.0.0 com.querydsl querydsl-sql-codegen 5.0.0 com.querydsl querydsl-sql-spatial 5.0.0 com.querydsl querydsl-sql-spring 5.0.0 com.rabbitmq amqp-client 5.13.1 com.rabbitmq stream-client 0.4.0 com.samskivert jmustache 1.15 com.sendgrid sendgrid-java 4.7.6 com.squareup.okhttp3 logging-interceptor 3.14.9 com.squareup.okhttp3 mockwebserver 3.14.9 com.squareup.okhttp3 okcurl 3.14.9 com.squareup.okhttp3 okhttp 3.14.9 com.squareup.okhttp3 okhttp-dnsoverhttps 3.14.9 com.squareup.okhttp3 okhttp-sse 3.14.9 com.squareup.okhttp3 okhttp-testing-support 3.14.9 com.squareup.okhttp3 okhttp-tls 3.14.9 com.squareup.okhttp3 okhttp-urlconnection 3.14.9 com.sun.activation jakarta.activation 1.2.2 com.sun.mail jakarta.mail 1.6.7 com.sun.xml.messaging.saaj saaj-impl 1.5.3 com.unboundid unboundid-ldapsdk 4.0.14 com.zaxxer HikariCP 4.0.3 commons-codec commons-codec 1.15 commons-pool commons-pool 1.6 de.flapdoodle.embed de.flapdoodle.embed.mongo 3.0.0 dev.miku r2dbc-mysql 0.8.2.RELEASE io.dropwizard.metrics metrics-annotation 4.2.7 io.dropwizard.metrics metrics-caffeine 4.2.7 io.dropwizard.metrics metrics-caffeine3 4.2.7 io.dropwizard.metrics metrics-collectd 4.2.7 io.dropwizard.metrics metrics-core 4.2.7 io.dropwizard.metrics metrics-ehcache 4.2.7 io.dropwizard.metrics metrics-graphite 4.2.7 io.dropwizard.metrics metrics-healthchecks 4.2.7 io.dropwizard.metrics metrics-httpasyncclient 4.2.7 io.dropwizard.metrics metrics-httpclient 4.2.7 io.dropwizard.metrics metrics-httpclient5 4.2.7 io.dropwizard.metrics metrics-jakarta-servlet 4.2.7 io.dropwizard.metrics metrics-jakarta-servlets 4.2.7 io.dropwizard.metrics metrics-jcache 4.2.7 io.dropwizard.metrics metrics-jdbi 4.2.7 io.dropwizard.metrics metrics-jdbi3 4.2.7 io.dropwizard.metrics metrics-jersey2 4.2.7 io.dropwizard.metrics metrics-jersey3 4.2.7 io.dropwizard.metrics metrics-jetty10 4.2.7 io.dropwizard.metrics metrics-jetty11 4.2.7 io.dropwizard.metrics metrics-jetty9 4.2.7 io.dropwizard.metrics metrics-jmx 4.2.7 io.dropwizard.metrics metrics-json 4.2.7 io.dropwizard.metrics metrics-jvm 4.2.7 io.dropwizard.metrics metrics-log4j2 4.2.7 io.dropwizard.metrics metrics-logback 4.2.7 io.dropwizard.metrics metrics-servlet 4.2.7 io.dropwizard.metrics metrics-servlets 4.2.7 io.lettuce lettuce-core 6.1.6.RELEASE io.micrometer micrometer-core 1.8.2 io.micrometer micrometer-jersey2 1.8.2 io.micrometer micrometer-registry-appoptics 1.8.2 io.micrometer micrometer-registry-atlas 1.8.2 io.micrometer micrometer-registry-azure-monitor 1.8.2 io.micrometer micrometer-registry-cloudwatch 1.8.2 io.micrometer micrometer-registry-cloudwatch2 1.8.2 io.micrometer micrometer-registry-datadog 1.8.2 io.micrometer micrometer-registry-dynatrace 1.8.2 io.micrometer micrometer-registry-elastic 1.8.2 io.micrometer micrometer-registry-ganglia 1.8.2 io.micrometer micrometer-registry-graphite 1.8.2 io.micrometer micrometer-registry-health 1.8.2 io.micrometer micrometer-registry-humio 1.8.2 io.micrometer micrometer-registry-influx 1.8.2 io.micrometer micrometer-registry-jmx 1.8.2 io.micrometer micrometer-registry-kairos 1.8.2

Spring Boot CLI – Discussion

Discuss Spring Boot CLI ”; Previous Next Spring Boot CLI is a command line tool, which is used for a quick start with Spring. It allows running Groovy scripts. Groovy scripts are similar to Java code without any boilerplate code. Spring CLI helps to bootstrap a new project or write custom command for it. Print Page Previous Next Advertisements ”;

Spring MVC – Generate Excel

Spring MVC – Generate Excel Example ”; Previous Next The following example shows how to generate Excel using the Spring Web MVC Framework. To begin with, let us have a working Eclipse IDE in place and stick to the following steps to develop a Dynamic Form based Web Application using the Spring Web Framework. Step Description 1 Create a project with a name TestWeb under a package com.tutorialspoint as explained in the Spring MVC – Hello World chapter. 2 Create Java classes UserExcelView and ExcelController under the com.tutorialspoint package. 3 Download the Apache POI library Apache POI from the maven repository page. Put it in your CLASSPATH. 4 The final step is to create the content of the source and configuration files and export the application as explained below. ExcelController.java package com.tutorialspoint; import java.util.HashMap; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.AbstractController; public class ExcelController extends AbstractController { @Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { //user data Map<String,String> userData = new HashMap<String,String>(); userData.put(“1”, “Mahesh”); userData.put(“2”, “Suresh”); userData.put(“3”, “Ramesh”); userData.put(“4”, “Naresh”); return new ModelAndView(“UserSummary”,”userData”,userData); } } UserExcelView.java package com.tutorialspoint; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.springframework.web.servlet.view.document.AbstractExcelView; public class UserExcelView extends AbstractExcelView { @Override protected void buildExcelDocument(Map<String, Object> model, HSSFWorkbook workbook, HttpServletRequest request, HttpServletResponse response) throws Exception { Map<String,String> userData = (Map<String,String>) model.get(“userData”); //create a wordsheet HSSFSheet sheet = workbook.createSheet(“User Report”); HSSFRow header = sheet.createRow(0); header.createCell(0).setCellValue(“Roll No”); header.createCell(1).setCellValue(“Name”); int rowNum = 1; for (Map.Entry<String, String> entry : userData.entrySet()) { //create the row data HSSFRow row = sheet.createRow(rowNum++); row.createCell(0).setCellValue(entry.getKey()); row.createCell(1).setCellValue(entry.getValue()); } } } TestWeb-servlet.xml <beans xmlns = “http://www.springframework.org/schema/beans” xmlns:context = “http://www.springframework.org/schema/context” xmlns:xsi = “http://www.w3.org/2001/XMLSchema-instance” xmlns:mvc = “http://www.springframework.org/schema/mvc” xsi:schemaLocation = ” http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd”> <bean class = “org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping” /> <bean class = “com.tutorialspoint.ExcelController” /> <bean class = “org.springframework.web.servlet.view.XmlViewResolver”> <property name = “location”> <value>/WEB-INF/views.xml</value> </property> </bean> </beans> views.xml <beans xmlns = “http://www.springframework.org/schema/beans” xmlns:context = “http://www.springframework.org/schema/context” xmlns:xsi = “http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation = ” http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd”> <bean id = “UserSummary” class = “com.tutorialspoint.UserExcelView”></bean> </beans> Here, we have created an ExcelController and an ExcelView. Apache POI library deals with Microsoft Office file formats and will convert the data to an excel document. Once you are done with creating source and configuration files, export your application. Right click on your application, use Export → WAR File option and save the TestWeb.war file in Tomcat”s webapps folder. Now, start the Tomcat server and make sure you are able to access other webpages from the webapps folder using a standard browser. Try a URL − http://localhost:8080/TestWeb/excel and we will see the following screen. Print Page Previous Next Advertisements ”;

Spring Boot CLI – Quick Guide

Spring Boot CLI – Quick Guide ”; Previous Next Spring Boot CLI – Overview The Spring Boot CLI is a Command Line Interface for Spring Boot. It can be used for a quick start with Spring. It can run Groovy scripts which means that a developer need not write boilerplate code; all that is needed is focus on business logic. Spring Boot CLI is the fastest way to create a Spring-based application. Features In this section, we will look at the different features of Spring Boot CL − It provides an interface to run and test Spring Boot Application from command prompt. It internally use Spring Boot Starter and Spring Boot AutoConfigurate components in order to resolve all dependencies and executes the application. It contains Groovy compiler and Grape Dependency Manager. It supports Groovy Scripts without external Groovy installation. It adds Spring Boot defaults and resolve all dependencies automatically. Spring Boot CLI – Environment Setup Spring is a Java-based framework; hence, we need to set up JDK first. Following are the steps needed to setup Spring Boot CLI along with JDK installation. Step 1 Setup Java Development Kit (JDK) You can download the latest version of SDK from Oracle”s Java site − Java SE Downloads. You will find instructions for installing JDK in downloaded files, follow the given instructions to install and configure the setup. Finally set PATH and JAVA_HOME environment variables to refer to the directory that contains java and javac, typically java_install_dir/bin and java_install_dir respectively. If you are running Windows and have installed the JDK in C:jdk-11.0.11, you would have to put the following line in your C:autoexec.bat file. set PATH=C:jdk-11.0.11;%PATH% set JAVA_HOME=C:jdk-11.0.11 Alternatively, on Windows NT/2000/XP, you will have to right-click on My Computer, select Properties → Advanced → Environment Variables. Then, you will have to update the PATH value and click the OK button. On Unix (Solaris, Linux, etc.), if the SDK is installed in /usr/local/jdk-11.0.11 and you use the C shell, you will have to put the following into your .cshrc file. setenv PATH /usr/local/jdk-11.0.11/bin:$PATH setenv JAVA_HOME /usr/local/jdk-11.0.11 Step 2 – Install Spring Boot CLI You can download the latest version of Spring Boot CLI API as ZIP archive from https://repo.spring.io/release/org/springframework/boot/spring-boot-cli/. Once you download the installation, unpack the zip distribution into a convenient location. For example, in E:Testspring-boot-cli-2.6.3 on Windows, or /usr/local/spring-boot-cli-2.6.3 on Linux/Unix. Make sure you set your CLASSPATH variable on this directory properly otherwise you will face a problem while running your application. Or set the path in command prompt temporarily to run the spring boot application as shown below − E:/Test/> set path=E:Testspring-boot-cli-2.6.3-binspring-2.6.3bin;%PATH% Step 3 – Verify installation Run the following command on command prompt to verify the installation − E:/Test/> spring –version It should print the following output confirming the successful installation − Spring CLI v2.6.3 Spring Boot CLI – Hello World Example In this example, we”ll create a Spring Boot + MVC + Rest based Web application. Step 1: Create source Folder Create a folder FirstApplication in E:Test folder. Step 2: Create Source File Create FirstApplication.groovy file in E:Test folder with following source code. @RestController class FirstApplication { @RequestMapping(“/”) String welcome() { “Welcome to TutorialsPoint.Com” } } Step 3: Run the application Type the following command E:/Test/> spring run FirstApplication.groovy Now Spring Boot CLI will come into action, download required dependencies, run the embedded tomcat, deploy the application and start it. You can see the following output on console. E:Test>spring run FirstApplication.groovy Resolving dependencies…………………………. . ____ _ __ _ _ /\ / ___”_ __ _ _(_)_ __ __ _ ( ( )___ | ”_ | ”_| | ”_ / _` | \/ ___)| |_)| | | | | || (_| | ) ) ) ) ” |____| .__|_| |_|_| |___, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.6.3) 2022-02-03 11:12:42.683 INFO 6956 — [ runner-0] o.s.boot.SpringApplication : Starting application using Java 11.0.11 on DESKTOP-86KD9FC with PID 6956 (started by intel in F:Test) 2022-02-03 11:12:42.710 INFO 6956 — [ runner-0] o.s.boot.SpringApplication : No active profile set, falling back to default profiles: default 2022-02-03 11:12:45.110 INFO 6956 — [ runner-0] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2022-02-03 11:12:45.138 INFO 6956 — [ runner-0] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2022-02-03 11:12:45.139 INFO 6956 — [ runner-0] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.56] 2022-02-03 11:12:45.229 INFO 6956 — [ runner-0] org.apache.catalina.loader.WebappLoader : Unknown class loader [org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader@8646db9] of class [class org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader] 2022-02-03 11:12:45.333 INFO 6956 — [ runner-0] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2022-02-03 11:12:45.333 INFO 6956 — [ runner-0] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2124 ms 2022-02-03 11:12:46.901 INFO 6956 — [ runner-0] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ”” 2022-02-03 11:12:46.930 INFO 6956 — [ runner-0] o.s.boot.SpringApplication : Started application in 5.416 seconds (JVM running for 49.049) 2022-02-03 11:13:48.910 INFO 6956 — [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet ”dispatcherServlet” 2022-02-03 11:13:48.912 INFO 6956 — [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet ”dispatcherServlet” 2022-02-03 11:13:48.915 INFO 6956 — [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 3 ms Step 4: Browse the application in Browser Our spring based rest application is now ready. Open url as “http://localhost:8080/” and you will see the following output. Welcome to TutorialsPoint.Com Points to consider Following actions are taken by Spring CLI. All dependency JARs are downloaded for the first time only. Spring CLI automatically detects which dependency JARs are to be downloaded based on the classes and annotations used in code. Finally it compiles the code, deploy the war on a embedded tomcat, start embedded tomcat server on the default port 8080. “grab”

Example – CheckBoxes

Swing Examples – CheckBoxes ”; Previous Next Learn how to play with CheckBoxes in Swing UI programming. Here are most commonly used examples − How to create and use Check box in a Java Swing application? How to create and use Radio buttons in a Java Swing application? How to make a radio button group in a Java Swing application? Print Page Previous Next Advertisements ”;

SWING – Overview

SWING – Overview ”; Previous Next Swing API is a set of extensible GUI Components to ease the developer”s life to create JAVA based Front End/GUI Applications. It is build on top of AWT API and acts as a replacement of AWT API, since it has almost every control corresponding to AWT controls. Swing component follows a Model-View-Controller architecture to fulfill the following criterias. A single API is to be sufficient to support multiple look and feel. API is to be model driven so that the highest level API is not required to have data. API is to use the Java Bean model so that Builder Tools and IDE can provide better services to the developers for use. MVC Architecture Swing API architecture follows loosely based MVC architecture in the following manner. Model represents component”s data. View represents visual representation of the component”s data. Controller takes the input from the user on the view and reflects the changes in Component”s data. Swing component has Model as a seperate element, while the View and Controller part are clubbed in the User Interface elements. Because of which, Swing has a pluggable look-and-feel architecture. Swing Features Light Weight − Swing components are independent of native Operating System”s API as Swing API controls are rendered mostly using pure JAVA code instead of underlying operating system calls. Rich Controls − Swing provides a rich set of advanced controls like Tree, TabbedPane, slider, colorpicker, and table controls. Highly Customizable − Swing controls can be customized in a very easy way as visual apperance is independent of internal representation. Pluggable look-and-feel − SWING based GUI Application look and feel can be changed at run-time, based on available values. Print Page Previous Next Advertisements ”;