Giter VIP home page Giter VIP logo

javaee-dac's Introduction

JAVAEE FROM CDAC

Cookie and Httpsession is important in terms of session managemnet, Cookie will help to identify client even after logoff from session, but seesion maintains current activity while client is connected with server.

Session

HttpSession session=req.getSession();

cookie

Cookie c= new Cookie("name"+,"value");
to access Cookie, we should store in an array and use foreach loop to getName() from cookies
Cookie[] c=req.getCookies();

started learning Spring

BEANS

beans definition should be written in cofiguration xml file

xml

the bean definition for XMl config

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns = "http://www.springframework.org/schema/beans"
   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">
  <bean name="car" class="Car"></bean>
   </beans>
``````````````````````````````````````````````````````````````````````````````````````````
####annotation based
for annotation based we also need definition in xml

definition for xml annotation

<context:component-scan base-package="l"></context:component-scan>

Spring STS

STS-4 --> MAVEN project in Spring starter --> add tools of web and java ee from eclips marketplace in sts else jsp will not created --> add tomcat jasper in dependency for jsp to servlet

@SpringBootApplication

this annoted class is a main (Dispatcher servlet)
IT will look for Controller where we marked Controller to a class
and @RequestMapping("/") will map the required method and returns the view.jsp file

to add jpa file it should be added in

src-main-webapp-a.jsp

we can also give direction to view resolver for locating jsp file in Properties

JPA

set properties dialect

spring.datasource.url=jdbc:mysql://localhost:3306/testhibernate
spring.datasource.username=root
spring.datasource.password=8052608851
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.ddl-auto=update

pom dependency

{


<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"> 4.0.0 org.springframework.boot spring-boot-starter-parent 2.1.2.RELEASE

<groupId>com.example</groupId>
<artifactId>firstBootMVC</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>firstBootMVC</name>
<description>first project for Spring Boot</description>
<properties>
	<java.version>1.8</java.version>
</properties>
<dependencies>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-web</artifactId>
	</dependency>

	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-test</artifactId>
		<scope>test</scope>
	</dependency>
	<!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-jasper -->
org.apache.tomcat tomcat-jasper 9.0.14 com.mysql mysql-connector-j 8.1.0
	<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
org.springframework.boot spring-boot-starter-data-jpa
</dependencies>

<build>
	<plugins>
		<plugin>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-maven-plugin</artifactId>
		</plugin>
	</plugins>
</build>
}

REST API

Add anotation as @ResponseBody which will let view know that ,Now he will convert response to json
use Optional (for handling null also)

javaee-dac's People

Contributors

mehdi9721 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.