javapandit.net
  • Home
  • Quick Java
    • Exception Handling
    • Collections Framework
  • Java Best Practices
  • Web Services
    • Web Service Basics
    • Ten Basic webservice concepts
    • XML
    • Apache Axis
    • Restful Web Services
  • JMS Concepts
    • JMS- MySQL
  • Hadoop
    • NoSQL DATABASEs
    • Apache Sqoop
    • Hadoop Interview Questions
  • Java 5
  • Java 8
    • Java 8 : Lambda Expressions
  • JDBC
  • Java Architect
    • Enterprise application re-platforming strategies
    • Java Memory Management
  • Java Programs
  • Technical Tips
    • How to set JAVA_HOME environment variable
    • How to create an auto increment field in Oracle?
    • Linux Commands
  • Best Java Interview Questions
    • Java Interview Questions- YouTube
  • Interview Questions
    • Java Tech interview Questions
    • Core Java Interview Questions >
      • core tech questions1
      • Java Collection interview questions
      • Java Concurrency
    • Servlets Interview Questions
    • JSP Interview Questions
    • Java Web Services Interview Questions
    • EJB Interview Questions
    • XML Interview Questions
    • JMS Interview Questions
  • Struts Interview Questions
    • Struts 2 Interview Questions
  • Java EE Architects Interview Questions
    • Java Architect Interview Questions
    • Top 10 reasons for Java Enterprise Application Performance Problems
    • Web Application Scalability Questions for IT Architect
  • JavaPandit's Blog
  • Web Services Interview Questions
  • Servlets And JSP
  • Oracle SOA Interview Questions
    • Open ESB /JBI
    • BPEL Language
  • Log4J
  • Ant
  • Maven
  • JMeter
  • JUnit
  • Apache POI Framework
  • ORCALE SERVICE BUS (OSB) Interview Questions
  • J2EE Patterns
    • Model-View-Controller (MVC)
    • Front Controller
    • DAO
    • Business Delegate
    • Session Facade
    • Service Locator
    • Transfer Object
    • Design Patterns >
      • Creational Patterns >
        • Singleton
      • Behavioural Patterns
      • Structural Patterns
    • Intercepting Filter
  • SQL Interview Questions/Lab
  • Best Wall Papers
    • Devotional Songs
  • Java Community
  • HIBERNATE
  • ORACLE CC&B
    • Oracle CC&B Interview Questions
  • Docker
  • Little Princess
    • Sai Tanvi Naming Ceremony Celebrations
    • Rice Feeding Ceremony
    • Sai Tanvi Gallery
  • APPSC Career Guidance
    • AP History
    • Indian Polity
    • Indian Economy
    • Science & Technology
    • Mental Ability and Reasoning
    • Disaster Management
    • Current Affairs and Events
    • General Sciences >
      • Biology
      • Physics
      • Chemistry
    • Previous Question Papers
  • About Us
  • Contact US

Java Server Pages (JSP)

Why JSP Technology :Servlets are good at running logic Not so good at producing large amounts of output

JSP pages are great at producing lots of textual output Not so good at lots of logic.

“JSP page” is Mixture of text, Script and directives

Text could be text/ html, text/ xml or text/ plain

 “JSP engine”
       'Compiles’ page to servlet Executes servlet’s service() method
       Sends text back to caller
        Page is Compiled once and Executed many times

Anatomy of a JSP

<%@ page language=“java” content“text/html” %>
<html>
<body bgcolor=“white”>
<jsp:useBean id=“greeting” “com.pramati.jsp.beans.GreetingBean”>
<jsp:setProperty name=“greeting” property=“*”/>
</jsp:userBean>

The following information was saved:
User Name:
<jsp:getProperty name=“greeting” property=“userName”/>
Welcome!
</body>
</html>

JSP Elements

•Directive Elements:– Informationabout the page
–Remains same between requests
–E.g., scripting language used

•Action Elements :  –Take action based on info required at request-time
•Standard
•Custom (Tags and Tag Libraries)
•Scripting Elements
–Add pieces of code to generate output based on conditions

Directives
•Global information used by the “JSP engine”
•Of form <%@ directive attr_ list %>
•Or <jsp: directive. directive attr_ list />

–Directive could be
•Page
•Include
•Taglib
–E. g.,
<%@ page info=“ written by DevelopMentor” %>
<jsp: directive. page import=“ java. sql.*” />
<%@ include file =“\ somefile. txt” %>
<%@ taglib    uri = tags prefix=“ foo” %>

Actions Within a JSP Page
•Specifies an action to be carried out by the “JSP engine”
•Standard or custom
–Standard must be implemented by all engines
–Custom defined in tag libraries

•Standard actions ‘scoped’ by ‘jsp’ namespace
•Have name and attributes

<jsp: useBean id=“ clock” “ java.util.Date” />
<ul> The current date at the server is:
         <li> Date:     <jsp: getProperty name=“clock” property=“date” />
        <li> Month: <jsp: getProperty name=“clock” property=“month” />
</ul>


Prev 1 2 3 Next
Powered by Create your own unique website with customizable templates.