Watch “JSP Part-6 | Action Tag with example (Gujarati)” on YouTube

Jdk #Java #JSP #JavaServerPages #Scriplet #JSPActionTags #Gujarati #RaviROza #JspInclude #JSPForward

Video features the following:

  • usage of Action tag
  • jsp:include
  • jsp-forward
  • jsp-param
  • Actions tags are used to do things without using Java inside the scriptlets.
  • They are used to control the flow between pages and to use Java Bean.
  • They can be used for specific task such as including other resource, forward the request to other resource (html/jsp/servlet), working with java bean objects

Following are the list of files used in example

  • header.jsp
  • index.jsp
  • page1.jsp
  • page2.jsp

header.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Header</title>
</head>
<body>
<center>
<h1> Ravi R. Oza </h1>
<h4> Home Page </h4>
<hr>
</center>
</body>
</html>
index.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>JSP Action Tag Demo</title>
</head>
<body>
<jsp:include page="header.jsp"></jsp:include>
<form action="page1.jsp">
<h1>JSP Action Tag Demo</h1>
<hr>
	<p> Enter your name 
		<input type="text" name="txtName">
	</p>
	<p>
		<input type="submit" value="Go to Page1">
	</p>

</form>
</body>
</html>
page1.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Page1</title>
</head>
<body>

<jsp:forward page="page2.jsp">
	<jsp:param value="Advance Java" name="txtSub"/>
</jsp:forward>

</body>
</html>
page2.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Testing Action tags with JSP Param</title>
</head>
<body>
<jsp:include page="header.jsp"></jsp:include>
<h1>Testing Action tags with JSP Param</h1>
<hr>
<p> Name : <%=request.getParameter("txtName") %>
<p> Subject : <%= request.getParameter("txtSub") %>
</body>
</html>

Summary:

  • Actions tags are used to do things without using Java inside the scriptlets.
  • They are used to control the flow between pages and to use Java Bean.
  • They can be used for specific task such as including other resource, forward the request to other resource (html/jsp/servlet), working with java bean objects

OS : Windows 10
Jdk : Version 8
IDE : Eclipse Mars
Server : Apache Tomcat 7

Follow me @
https://raviroza.wordpress.com/
https://raviroza.blogspot.com/
https://www.facebook.com/ravi.oza.it
https://twitter.com/raviozaIT

Subscribe my channel to get latest video notification https://www.youtube.com/user/ravioza101

Watch “JSP Part-5 | Page Directive attributes example (Gujarati)” on YouTube

Jdk #Java #JSP #JavaServerPages #Scriplet #PageDirectiveAttributes #Gujarati #RaviROza

Video features the following:

  • usage of page attributes in JSP

Following are the list of files used in example

  • index.jsp
  • myerror.jsp
index.jsp
<%@ page 	
	language="java" 
	contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"  
    errorPage="/myerror.jsp"         
    %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>JSP Page Directives</title>
</head>
<body>
<h1>JSP Page Directives Demo</h1>
<h3>Ravi R. Oza</h3>
<hr/>

<%
	String name = null;
	int n = name.length();
        //   or try below
	//int n=100/0;
%>
</body>
</html>
myerror.jsp
<%@ page isErrorPage="true" %>

<h1> OOPS, There is an Error</h1>

<h2> Please check the input or wait for server to response.</h2>
<font color="red">
 
<%= exception %>
</font>

Summary

  • It is used to provide instructions to a container that connect to current JSP page.
  • It defines page dependent properties/attributes such as scripting language, error page, etc., which communicates with the Web Container at the time of page translation.

OS : Windows 10
Jdk : Version 8
IDE : Eclipse Mars
Server : Apache Tomcat 7

Follow me @
https://raviroza.wordpress.com/
https://raviroza.blogspot.com/
https://www.facebook.com/ravi.oza.it
https://twitter.com/raviozaIT

Subscribe my channel to get latest video notification https://www.youtube.com/user/ravioza101

Watch “JSP-4 | Include Directive example (Gujarati)” on YouTube

Jdk #Java #JSP #JavaServerPages #Scriplet #IncludeDirectiveTag #IncludeDirective #Gujarati #RaviROza

Video features the following:

  • Usage of Include Directive tag
  • Inclusion of any java/html/jsp resource in jsp file

Following are the list of files used in example

  • index.jsp
  • header.html
  • footer.html
  • search.jsp
  • about.jsp
  • contact.jsp
index.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>JSP Include Tag Example</title>
</head>
<body>
<%@ include file="header.html" %>

<h2>Content of index page is this </h2>
<p> <p> <p> <p> <p> <p> <p> <p> 



<%@ include file="footer.html" %>
</body>
</html>
header.html
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>header</title>
</head>
<body>

<h1 align="center">Ravi R. Oza (header)</h1>
<p align="right">
<a href="index.jsp"> Home </a> |
<a href="search.jsp"> Search </a> | 
<a href="contact.jsp"> Contact </a>|
<a href="about.jsp"> About </a>
<hr/>
</p> 
</body>
</html>
footer.html
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>footer</title>
</head>
<body>

<hr/>
<p align="center">

<h3>2020 Copyrights reserved to RaviROza (footer)</h3>

</p>

</body>
</html>
search.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta charset="ISO-8859-1">
<title>search</title>
</head>
<body>
<%@ include file="header.html" %>

<h2> SEARCH  </h2>
Search : <input type="text">
<p> <p> <p> <p> <p> <p> <p> <p> 

<%@ include file="footer.html" %>
</body>
</html>
about.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta charset="ISO-8859-1">
<title>contact</title>
</head>
<body>
<%@ include file="header.html" %>

<h3>About me  </h3>
<h2> Myself Ravi R. Oza </h2>
<h4> Myself Educator, Blogger, YouTuber, Learner </h4> 

<p> <p> <p> <p> <p> <p> <p> <p> 

<%@ include file="footer.html" %>
</body>
</html>
contact.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta charset="ISO-8859-1">
<title>contact</title>
</head>
<body>
<%@ include file="header.html" %>

<h2>Contact me  </h2>
<p> Mail me : Ravi.oza.it@gmail.com
<p> Follow me on Youtube @RaviROza
<p> <p> <p> <p> <p> <p> <p> <p> 

<%@ include file="footer.html" %>
</body>
</html>

In this example index page used as home page.
Header.jsp contains the header information such as website name, logo & menus.
Footer.jsp contains the footer information such as quick links, company’s policies etc.,
Search.jsp is used to find the information from website.
About.jsp is the page which holds the info related to company history & its objective past and future work
Contact.jsp is the contact page which is useful when client want to communicate with the company.

Summary:
JSP Include Directive is the best way to have reuseability, where a the content of one page or resources can be merged to existing Jsp

OS : Windows 10
Jdk : Version 8
IDE : Eclipse Mars
Server : Apache Tomcat 7

Follow me @
https://raviroza.wordpress.com/
https://twitter.com/raviozaIT
https://www.facebook.com/ravi.oza.it

Subscribe my channel to get latest video notification https://www.youtube.com/user/ravioza101

Watch “JSP Part-3 | Declaration tag example (Gujarati)” on YouTube

Jdk #Java #JSP #JavaServerPages #Scriplet #DeclarationTag #JSPDeclarationTag #Delimiters #Gujarati #RaviROza

Video features the combination of following

  • Scriplet tag example in JSP
  • Expression tag example in JSP
  • Comment tag example in JSP

If we declare them in declaration tag, both variables, objects & methods, they will be accessible throughout that page. It is used declare public objects or methods for the current page, every scriplet in current page can access it.

OS : Windows 10
Jdk : Version 8
IDE : Eclipse Mars
Server : Apache Tomcat 7

follow me @
https://raviroza.wordpress.com/
https://twitter.com/raviozaIT
https://www.facebook.com/ravi.oza.it

Subscribe my channel to get latest video notification https://www.youtube.com/user/ravioza101

Watch “JSP Part-2 | JSP Login example (Gujarati)” on YouTube

Jdk #Java #JSP #JavaServerPages #Scriplet #Delimiters #JSPLogin #LoginExampleUsingJSP #Gujarati #RaviROza

Video features the combination of following

  • Scriplet tag example in JSP
  • Expression tag example in JSP
  • Comment tag example in JSP

Following are the files used in the JSP login example

  • index.jsp
  • login.jsp
  • welcome.jsp
  • sorry.jsp

Overall process of example:
index.jsp page contains user interface to accept username and password from client side, when client submits the control transfer to the login.jsp file which contains the logic to validate username and password. If the client information is validated the control is transfer to welcome.jsp otherwise to sorry.jsp.

OS : Windows 10
Jdk : Version 8
IDE : Eclipse Mars
Server : Apache Tomcat 7

follow me @
https://raviroza.wordpress.com/
https://twitter.com/raviozaIT
https://www.facebook.com/ravi.oza.it

Subscribe my channel to get latest video notification https://www.youtube.com/user/ravioza101

Watch “Introduction to RMI – Remote Method Invocation (Gujarati)” on YouTube

RMI #RemoteMethodInvocation #Jdk #Java #Gujarati #RemoteProcedureCall #Stub #Skeleton #RaviROza

RMI Introduction:

RMI is an API that provides a mechanism to develop distributed app, objects on different computers can interact in a distributed network.
It allows an object to invoke methods on an object running in another JVM.
RMI is the Java version of what is generally known as a remote procedure call (RPC), but with the ability to pass one or more objects along with the request.
The object can include information that will change the service that is performed in the remote computer.
The RMI provides remote communication between the applications using two objects stub and skeleton.

  • various sources

OS : Windows 10
Jdk : Version 8

follow me @
https://raviroza.wordpress.com/
https://twitter.com/raviozaIT
https://www.facebook.com/ravi.oza.it

Subscribe my channel to get latest video notification https://www.youtube.com/user/ravioza101

Watch “Servlet Part 21 | CRUD operation in Servlet Using JDBC (Gujarati)” on YouTube

#CRUD #Servlet #JDBC #MySql #Eclipse #MySqlWorkbench #ApacheTomcat #Jdk #Java

This video features the CRUD operation using JDBC via servlet only, no JSP page is used to perform any database operation.
CRUD is Create, Read, Update & Delete.

Index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Servlet with JDBC</title>
</head>
<body>
<form action="AddEmp" method="post">
<h1> Employee Management</h1>
<p> Enter Emp. No : <input type="text" name="txtEno"> </p>
<p> Enter Emp. Name : <input type="text" name="txtEname"> </p>
<p> Enter Emp. Salary : <input type="text" name="txtEsalary"> </p>

<p> DB Operation :
<select name="op">
    <option value="1">Add</option>
    <option value="2">Update</option>
    <option value="3">Delete</option>
    <option value="4">Display</option>
</select>
</p>

<p> <input type="submit" value="Submit"> </p>
</form>
</body>
</html>

AddEmp.java

package servletWithJDBC;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;

@WebServlet("/AddEmp")
public class AddEmp extends HttpServlet 
{
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{			
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		String op = request.getParameter("op");
		Connection conn;
		PreparedStatement pst=null; 
		String url,username,password,qry="";
		url = "jdbc:mysql://localhost:3306/raviroza";
		username="root";
		password="ravi";	
		
		int eno;
		String ename="";
		float esalary;
		try 
		{
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection(url,username,password);			
			
			if(op.equals("1"))
			{
				eno = Integer.parseInt(request.getParameter("txtEno"));
				ename = request.getParameter("txtEname");
				esalary = Float.parseFloat(request.getParameter("txtEsalary"));
				
				qry = "insert into emp values (?,?,?)";
				pst = conn.prepareStatement(qry);
				pst.setInt(1, eno);
				pst.setString(2, ename);
				pst.setFloat(3, esalary);
				pst.executeUpdate();
			}
			else if(op.equals("2"))
			{
				eno = Integer.parseInt(request.getParameter("txtEno"));
				ename = request.getParameter("txtEname");
				esalary = Float.parseFloat(request.getParameter("txtEsalary"));
				
				qry = "update emp set ename=?,esalary=? where eno=?";
				pst = conn.prepareStatement(qry);				
				pst.setString(1, ename);
				pst.setFloat(2, esalary);
				pst.setInt(3, eno);
				pst.executeUpdate();
			}
			else if(op.equals("3"))
			{
				eno = Integer.parseInt(request.getParameter("txtEno"));
				qry = "delete from emp where eno=?";	
				pst = conn.prepareStatement(qry);								
				pst.setInt(1, eno);
				pst.executeUpdate();
			}								
						
			qry = "select * From Emp Order by eno desc";
			ResultSet rs = conn.prepareStatement(qry).executeQuery();
			pw.println("<table border=1>");
			pw.println("<th>Eno.</th>");
			pw.println("<th>Emp. Name</th>");
			pw.println("<th>Emp. Salary</th>");
			while(rs.next())
			{
				pw.println("<tr>");
				pw.println("<td>"+rs.getString("eno")+"</td>");
				pw.println("<td>"+rs.getString("ename")+"</td>");
				pw.println("<td>"+rs.getString("esalary")+"</td>");
				pw.println("</tr>");
			}
						
			pw.println("<h2> Employee Info. updated Successfully ! </h2>");
			pw.println("<a href='index.html'>Back</a>");
			
			pw.close();
			pst.close();
			conn.close();		
		}
		catch (ClassNotFoundException | SQLException e) 
		{
			pw.println("<h2> Driver|SQL Error "+e.toString() +"</h2>");
		}
	}
}

Overall process of example.

It is generally the table operation to create, access, manipulate, and delete the data from a database table.
Here, only a single Servlet is performing all the CRUD operation. Operation is decided by the client by selecting a proper option from list of choices.

When a client/user select the “Add” option, the internal value of that option is checked to perform the add operation, like wise when user/client select the “Update” operation the record is updated with given details.

If user/client decide to delete the record the valid number is given and the delete operation is carried.

Finally, if user decides to display all the record there is an option called “Display” to view all the details of the table.

OS : Windows 10
Jdk : Version 8
IDE : Eclipse Mars
Database : MySQL using MySql Workbench 5.2 CE
Server : Apache Tomcat 7

follow me @
https://raviroza.wordpress.com/
https://twitter.com/raviozaIT
https://www.facebook.com/ravi.oza.it

Subscribe my channel to get latest video notification https://www.youtube.com/user/ravioza101