Master java skills

request Implicit Object

request implicit object represents http request object. And it can be used to get information from the request such as parameter, header information, remote address, server name, server port, content type, character encoding etc.

Consider the below example

Create a maven project and add below dependencies.

pom.xml

<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>
	<groupId>com.sks</groupId>
	<artifactId>my-first-jsp-app</artifactId>
	<version>0.0.1-SNAPSHOT</version>

	<dependencies>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>javax.servlet-api</artifactId>
			<version>4.0.1</version>
			<scope>provided</scope>
		</dependency>

	</dependencies>

</project>

index.html

<html>
  <body>
    <form action="introduction.jsp">  
      Username : <input type="text" name="username"><br><br>
      Email : <input type="text" name="email"><br><br>  
      <input type="submit" value="Submit"><br/>  
    </form>  
  </body>
</html>

introduction.jsp

<html>
  <body>
    <%   
      String name = request.getParameter("username");
      String email = request.getParameter("email");
      out.print("Welcome " + name + "<br>");
      out.print("Your email id :  " + email + "<br>");
    %>  
  </body>
</html>

Run and test.