NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

JSP - Java Server Pages (JSP) is a technology for creating dynamic web pages.
JSP creates dynamic web pages with embedded Java code for server-side processing.
Combines HTML with Java to simplify web development.
JSP is a specialized type of servlet, simplifying Java-based web application development.
Supports the MVC model.
Tag-based Syntax : Uses custom tags for Java code, improving readability and reducing complexity in web pages.
JSP Processing - JSP pages contain HTML code mixed with Java code enclosed in special tags.
<%...%> tags enclose Java code, while <%=...%> tags output Java expressions.
JSP mixes HTML with snippets of Java code.
Server translates JSP to a real Java program.
Program runs and generates dynamic content.
Final HTML with data is sent to your browser.
Finally we get a Dynamic Web page .
JSP declarations - Declarations start with <%! and end with %> in a JSP page.
JSP declarations are used to define variables and methods at the class level.
Declared variables and methods are accessible across the entire JSP page.
Declarations improve code organization.
JSP Directives - page directive (<%@ ... %>): Sets page properties like character encoding or scripting language.
Include Directive (<%@ include %>): Inserts content from another file during page translation.
Taglib Directive (<%@ taglib %>): Makes custom tags available for use within the JSP page.
JSP expressions - JSP expressions are shortcuts to print data in your JSP.
They use <%= %> tags and insert Java expressions as strings.
Enhances code readability.
Examples: <%= variable %>.
JSP code snippets - Declaration : <%! int count = 0; %>.
Scriptlet : <% for (int i = 0; i < 5; i++) { %> ... <% } %>.
Custom Tag : <custom:tag attribute="value" />.
Directives and Expressions.
JSP Implicit objects - out: Send data to the browser (like System.out.print in Java). -> out.println("Output text");
request: Access information from user submissions (forms). -> request.getAttribute("attributeName")
response: Control what the browser sees (like sending headers).
session: Store user data across page visits (like shopping carts). -> session.setAttribute("username");
application: Share data across all JSP pages in your app. -> application.setAttribute("appName");
Java beans in JSP - JavaBeans in JSP are reusable Java components for building dynamic and modular web applications.
It provides a default, no-argument constructor.
JavaBeans support getter and setter methods for accessing and updating their properties.
A JavaBean properties are read, write, read only, or write only.
JavaBean properties are accessed through two methods : getPropertyName() - to read that property
setPropertyName() - to write the property.
Along with <jsp:useBean...> action, you can use the <jsp:getProperty/> action to access the get methods and the <jsp:setProperty/> action to access the set methods.
Using Cookies and session for session tracking - JSP offers two ways to track user sessions:
Cookies : Tiny data packets stored on the user's browser.
Server sends a unique ID as a cookie in the response.
Browser sends the ID back with future requests for identification.
Sessions : Server stores user data on its side during the session.
A unique session ID is used to link requests to the user's data.
Session data is lost when the browser closes or times out.
HttpSession stores data between requests for a specific user during a session.
Connecting to database in JSP - JSP relies on JDBC (Java Database Connectivity) to connect to databases.
JDBC Driver: Download the driver for your database (e.g., MySQL, Oracle).
Use DriverManager.getConnection to connect to the database.
Prepare SQL statements for queries or updates using Connection.createStatement or Connection.prepareStatement.
Execute queries with Statement.executeQuery or updates with Statement.executeUpdate.
Always close the database connections using Connection.close to manage resources effectively.
Simple JSP code ->
<%@ page import="java.util.Date" %>
<html>
<body>
<h2>Welcome to My JSP Page!</h2>
<p>Current Date: <%= new Date() %></p>
<%
String message = "Hello, JSP!";
out.println("<p>" + message + "</p>");
%>
</body>
</html>.



     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.