Skip to main content

The Future of Web Development: Why Next.js is Going Viral

  Are you ready to level up your web development game? Look no further than Next.js, the latest sensation in the world of web development that's taking the industry by storm. With its powerful features, flexibility, and performance optimizations, Next.js is becoming the go-to framework for building modern web applications. In this blog post, we'll explore why Next.js is going viral and how it's changing the landscape of web development. Supercharged Performance: One of the main reasons why Next.js is making waves is its superior performance capabilities. With built-in optimizations like automatic static site generation (SSG) and server-side rendering (SSR), Next.js allows you to create blazing-fast web applications that load quickly and deliver seamless user experiences. This is especially important in today's fast-paced digital world, where users demand instant gratification and have little patience for slow-loading websites. Flexibility and Scalability: Next.js provid...

Write a JSP which insert the details of the 3 or 4 users who register with the web site by using registration form. Authenticate the user when he submits the login form using the user name and password from the database

Write a JSP which does the following job
 Insert the details of the 3 or 4 users who register with the web site (week9) by using registration form. Authenticate the user when he submits the login form using the user name and password from   the database (similar to week8 instead of cookies).

Description

JSP scripting elements let you insert Java code into the servlet that will be generated from the current JSP page. There are three forms:
  1. Expressions of the form <%= expression %> that are evaluated and inserted into the output,
  2. Scriptlets of the form <% code %> that are inserted into the servlet's service method, and
  3. Declarations of the form <%! code %> that are inserted into the body of the servlet class, outside of any existing methods.
Each of these is described in more detail below.

JSP Expressions

A JSP expression is used to insert Java values directly into the output. It has the following form:
               <%= Java Expression %>
The Java expression is evaluated, converted to a string, and inserted in the page. This evaluation is performed at run-time (when the page is requested), and thus has full access to information about the request. For example, the following shows the date/time that the page was requested:
               Current time: <%= new java.util.Date() %>
To simplify these expressions, there are a number of predefined variables that you can use. These implicit objects are discussed in more detail later, but for the purpose of expressions, the most important ones are:
  • request, the HttpServletRequest;
  • response, the HttpServletResponse;
  • session, the HttpSession associated with the request (if any); and
  • out, the PrintWriter (a buffered version of type JspWriter) used to send output to the client.

JSP Scriptlets

If you want to do something more complex than insert a simple expression, JSP scriptlets let you insert arbitrary code into the servlet method that will be built to generate the page. Scriptlets have the following form:
               <% Java Code %>
Scriptlets have access to the same automatically defined variables as expressions. So, for example, if you want output to appear in the resultant page, you would use the out variable.
<% 
String queryData = request.getQueryString();
out.println("Attached GET data: " + queryData); 
%>
               Note that code inside a scriptlet gets inserted exactly as written, and any static HTML (template text) before or after a scriptlet gets converted to print statements. This means that scriptlets need not contain complete Java statements, and blocks left open can affect the static HTML outside of the scriptlets. 

JSP Declarations

A JSP declaration lets you define methods or fields that get inserted into the main body of the servlet class (outside of the service method processing the request). It has the following form:
<%! Java Code %>
Since declarations do not generate any output, they are normally used in conjunction with JSP expressions or scriptlets. For example, here is a JSP fragment that prints out the number of times the current page has been requested since the server booted (or the servlet class was changed and reloaded):
<%! private int accessCount = 0; %>
PROGRAM:
Login.html:
<!--Home.html-->
<html> <body>
<center><h1>XYZ Company Ltd.</h1></center>
<table border="1" width="100%" height="100%">
<tr>
            <td valign="top" align="center"><br/>
                                    <form action="auth.jsp"><table>
                                    <tr>
                                         <td colspan="2" align="center"><b>Login Page</b></td>
                                    </tr>
                                    <tr>
                                         <td colspan="2" align="center"><b>&nbsp;</td>
                                    </tr>
                                    <tr>
                                           <td>User Name</td>
                                           <td><input type="text" name="user"/></td>
                                    </tr>
                                    <tr>
                                           <td>Password</td>
                                              <td><input type="password" name="pwd"/></td>
                                    </tr>
                                    <tr>
                                              <td>&nbsp;</td>
                                              <td>&nbsp;</td>
                                    </tr>
                                    <tr>
                       <td colspan="2" align="center"><input type="submit" value="LogIN"/></td>
                                    </tr>
                                    </table>
                                    </form>
            </td>
</tr>
</table>
</body>
</html>
Auth.jsp:
<%@page import="java.sql.*;"%>
<html>
<head>
<title>
This is simple data base example in JSP</title>
</title>
</head>
<body bgcolor="yellow">
<%!String uname,pwd;%>
<%
uname=request.getParameter("user");
pwd=request.getParameter("pwd");
  try
{
  Class.forName("oracle.jdbc.driver.OracleDriver");
  Connection con=DriverManager.getConnection("jdbc:oracle:thin:@195.100.101.158:1521:CCLAB","scott","tiger");
  Statement st=con.createStatement();
  ResultSet rs=st.executeQuery("select name,password from personal where name='"+uname+"' and password='"+pwd+"'");
  if(rs.next())
{
out.println("Authorized person");
}
else
{
out.println("UnAuthorized person");
}
con.close();
}
catch(Exception e){out.println(""+e);}
%>
</body>
</html>
OUTPUT:

http://wikibrand.blogspot.in
http://wikibrand.blogspot.in
http://wikibrand.blogspot.in
RESULT:

The user is authenticated when he submits the login form using the user name and password from   the database.

Comments

Popular posts from this blog

The Future of Web Development: Why Next.js is Going Viral

  Are you ready to level up your web development game? Look no further than Next.js, the latest sensation in the world of web development that's taking the industry by storm. With its powerful features, flexibility, and performance optimizations, Next.js is becoming the go-to framework for building modern web applications. In this blog post, we'll explore why Next.js is going viral and how it's changing the landscape of web development. Supercharged Performance: One of the main reasons why Next.js is making waves is its superior performance capabilities. With built-in optimizations like automatic static site generation (SSG) and server-side rendering (SSR), Next.js allows you to create blazing-fast web applications that load quickly and deliver seamless user experiences. This is especially important in today's fast-paced digital world, where users demand instant gratification and have little patience for slow-loading websites. Flexibility and Scalability: Next.js provid...

Importants Links of Leetcode

  Here are all the important discussion posts which contain brief descriptions about a topic with its problem list. Recursion:- A.   https://leetcode.com/tag/recursion/discuss/1733447/Become-Master-In-Recursion Binary Tree and Binary Search Tree:- A.   https://leetcode.com/tag/binary-tree/discuss/1212004/Binary-Trees-study-guide B.   https://leetcode.com/tag/binary-tree/discuss/1820334/Become-Master-in-Tree C.   https://leetcode.com/tag/binary-tree/discuss/1094690/Views-and-Traversal-of-binary-tree-or-Important-topics-or-Must-Read-%3A- ) Dynamic Programming:- A.   https://leetcode.com/discuss/study-guide/458695/Dynamic-Programming-Patterns B.   https://leetcode.com/tag/dynamic-programming/discuss/1437879/Dynamic-Programming-Patterns C.   https://leetcode.com/tag/dynamic-programming/discuss/662866/DP-for-Beginners-Problems-or-Patterns-or-Sample-Solutions D.   https://leetcode.com/tag/dynamic-programming/discuss/1050391/Must-do-Dynamic-programm...

The Ultimate Guide: How to Become a Tech YouTuber

 The Ultimate Guide: How to Become a Tech YouTuber Are you passionate about technology and want to share your knowledge with others? Becoming a tech YouTuber can be a rewarding and exciting venture that allows you to create content about your favorite gadgets, software, and tech-related topics. With millions of viewers and subscribers on YouTube, the potential for success is immense. However, starting a tech YouTube channel requires careful planning, creativity, and dedication. In this blog, we will provide you with the ultimate guide on how to become a tech YouTuber. Identify Your Niche: Technology is a broad field, and it's essential to identify your specific niche before starting your YouTube channel. Consider what aspects of technology you are most passionate about and have expertise in. It could be smartphone reviews, software tutorials, gaming, programming, or any other tech-related topic. Choosing a specific niche will help you target a particular audience and create content...