Lets explain that what is static in java.
if we make a class static then it means members of this class will be accessed directily by class name.and we can not create instanse of this class.
only static mamber can access to other static member.
if any non-static member want to access any non-static member then it need to access throught the instance of that class
Aptitude
(12)
C
(2)
C++
(10)
CSS
(1)
Data Structure
(2)
English
(6)
Fitness
(2)
General
(14)
HTML
(3)
Integration
(1)
Itinerary and Travel Cost
(2)
Java
(29)
JQ
(5)
JS
(5)
JSP
(1)
Lightning
(14)
logical
(3)
Lyrics
(1)
Math
(1)
Music Notation
(20)
MySql
(4)
Network
(1)
Regex
(1)
salesforce
(131)
Servlet
(4)
SF Admin
(31)
SF Dev
(102)
Spiritual Content
(3)
SQL
(4)
SQL_SERVER
(1)
StudyPoints
(2)
Trips
(1)
ytChannels
(2)
अन्ताक्षरी
(4)
Custom Exception
Defining your own Exception class in JAVA
Now you know how to write exception handlers for those exception objects that are thrown by the runtime system, and thrown by a method in the standard class library.
It is also possible for you to define your own exception classes and to cause objects of those classes to be thrown whenever an exception occur. In this case, you get to decide just what constitutes an exceptional condition. For example, suppose you could write a data-processing application that processes integer data obtained via a TCP/IP link from another computer. If the specification for the program indicates that the integer value 100 should never be received, then you could use an occurrence of the integer value 100 to cause an exception object of your own design to be thrown.
Exception Types
Mainly Exceptions are of two types; checked and unchecked exceptions:
The two existing subclasses of Throwable are Exception and Error. Example-1
This example is making your own Exception class by using constructor.
// this is a user define exception class etend by Exception class
class Myexception extends Exception
{
public Myexception(int i)
{
System.out.println("you " +i +" entered It exceeding the limit");
}
}
public class ExceptionTest
{
public void show(int i) throws Myexception
{
if(i>100)
throw new Myexception(i);
else
System.out.println(+i+" is less then 100 it is ok");
}
public static void main(String []args)
{
int i=Integer.parseInt(args[0]);
int j=Integer.parseInt(args[1]);
ExceptionTest t=new ExceptionTest();
try{
t.show(i);
t.show(j);
}
catch(Throwable e)
{
System.out.println("catched exception is"+e);
}
}
}
OUTPUT
Example-2
This example is making your own Exception class by using super keyword.
class MyException extends Exception
{
MyException(String s)
{
super(s);
}
public String toString()
{
return(" " + getMessage());
}
}class ThrowClass {
int age;
ThrowClass(int age) throws MyException
{
this.age=age;
}
void getAge(int age) throws MyException
{
if(age <18 )
{
throw new MyException("Invalid Age");
}
else
{
this.age=age;
}
}
}
class TestException {
Now you know how to write exception handlers for those exception objects that are thrown by the runtime system, and thrown by a method in the standard class library.
It is also possible for you to define your own exception classes and to cause objects of those classes to be thrown whenever an exception occur. In this case, you get to decide just what constitutes an exceptional condition. For example, suppose you could write a data-processing application that processes integer data obtained via a TCP/IP link from another computer. If the specification for the program indicates that the integer value 100 should never be received, then you could use an occurrence of the integer value 100 to cause an exception object of your own design to be thrown.
Exception Types
Mainly Exceptions are of two types; checked and unchecked exceptions:
- Error and Runtime Exception are unchecked these exception not handled or check by compiler that you handle them explicitly
- All other Exception are checked that is compiler enforce or check that you can handle them explicitly
- Running out of memory
- Infinite recursion
- Inability to link
- Use the Exception class in the API.
- Create a Custom Exception class if the predefined class is not sufficient.
- Declare a custom exception classes by extending the Exception class or a subclass of Exception.
The two existing subclasses of Throwable are Exception and Error. Example-1
This example is making your own Exception class by using constructor.
// this is a user define exception class etend by Exception class
class Myexception extends Exception
{
public Myexception(int i)
{
System.out.println("you " +i +" entered It exceeding the limit");
}
}
public class ExceptionTest
{
public void show(int i) throws Myexception
{
if(i>100)
throw new Myexception(i);
else
System.out.println(+i+" is less then 100 it is ok");
}
public static void main(String []args)
{
int i=Integer.parseInt(args[0]);
int j=Integer.parseInt(args[1]);
ExceptionTest t=new ExceptionTest();
try{
t.show(i);
t.show(j);
}
catch(Throwable e)
{
System.out.println("catched exception is"+e);
}
}
}
OUTPUT
Example-2
This example is making your own Exception class by using super keyword.
class MyException extends Exception
{
MyException(String s)
{
super(s);
}
public String toString()
{
return(" " + getMessage());
}
}class ThrowClass {
int age;
ThrowClass(int age) throws MyException
{
this.age=age;
}
void getAge(int age) throws MyException
{
if(age <18 )
{
throw new MyException("Invalid Age");
}
else
{
this.age=age;
}
}
}
class TestException {
public static void main(String [] args)
{
int a=Integer.parseInt(args[0]);
try {
ThrowClass t=new ThrowClass(a);
t.getAge(a);
System.out.println(t.age);
}
catch(MyException me)
{
System.out.println(me);
}
}
}
{
int a=Integer.parseInt(args[0]);
try {
ThrowClass t=new ThrowClass(a);
t.getAge(a);
System.out.println(t.age);
}
catch(MyException me)
{
System.out.println(me);
}
}
}
OUTPUT
Aggregate Functions:
They are used to compute a single value from a set of attribute values of a column:
count :
how many rows(tuples) are stored in the relation
EMP
select count(*) from EMP;
how many different job title are stored in the relation EMP
select count(distinct job)
from EMP;
max & min:
select min(SAL),max(SAL) from EMP
select max(SAL)-
min(SAL) from EMP
sum:
select
sum(SAL) from EMP
avg:
PL/SQL
Structure of PL/SQL:
Declare
<Constants>
<Variables>
<Cursors>
<User defined exceptions>
Begin
<PL/SQL
Statements>
exception
<exception
handling>
End
Know in PL/SQL:
About
1.Exception handling
2.Procedures
3.Functions
4.assertions
5.Triggers
Tags
<abbr> Tag
The
<abbr> tag is supported in all major browsers.
<abbr title="World Health
Organization">WHO</abbr>
Note: The <abbr> tag is not
supported in IE 6 or earlier versions.
Tip: The global title attribute can
be used in the <abbr> tag to show the full version of the
abbreviation/acronym when you mouse over the <abbr> element.
<acronym> Tag
<acronym
title="as soon as possible">ASAP</acronym>
<bdo> Tag
<bdo dir="rtl">
This text will go right-to-left.
</bdo>
This text will go right-to-left.
</bdo>
<caption> Tag
<table border="1">
<caption>Monthly savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
<caption>Monthly savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
The <caption> tag defines a table caption.
<col> Tag
table border="1">
<colgroup>
<col span="2" style="background-color:red">
<col style="background-color:yellow">
</colgroup>
<tr>
<th>ISBN</th>
<th>Title</th>
<th>Price</th>
</tr>
<tr>
<td>3476896</td>
<td>My first HTML</td>
<td>$53</td>
</tr>
</table
<colgroup>
<col span="2" style="background-color:red">
<col style="background-color:yellow">
</colgroup>
<tr>
<th>ISBN</th>
<th>Title</th>
<th>Price</th>
</tr>
<tr>
<td>3476896</td>
<td>My first HTML</td>
<td>$53</td>
</tr>
</table
<del> Tag
<p>My
favorite color is <del>blue</del>
<ins>red</ins>!</p>
<fieldset> Tag
<!DOCTYPE html>
<html>
<body>
<form>
<fieldset>
<legend>Personalia:</legend>
Name: <input
type="text"><br>
Email: <input
type="text"><br>
Date of birth:
<input type="text">
</fieldset>
</form>
</body>
</html>
<hr> Tag
<!DOCTYPE html>
<html>
<body>
<h1>HTML</h1>
<p>HTML is a language for describing web
pages.</p>
<hr>
<h1>CSS</h1>
<p>CSS defines how to display HTML
elements.</p>
</body>
</html>
<mark> Tag
<!DOCTYPE html>
<html>
<body>
<p>Do not forget to buy
<mark>milk</mark> today.</p>
</body>
</html>
<meter> Tag
<!DOCTYPE html>
<html>
<body>
<p>Display a gauge:</p>
<meter value="2" min="0"
max="10">2 out of 10</meter><br>
<meter value="0.6">60%</meter>
<p><b>Note:</b> The <meter>
tag is not supported in IE and Safari.</p>
</body>
</html>
<nav> Tag
<!DOCTYPE html>
<html>
<body>
<nav>
<a href="/html/">HTML</a> |
<a href="/css/">CSS</a> |
<a href="/js/">JavaScript</a> |
<a href="/jquery/">jQuery</a>
</nav>
</body>
</html>
<optgroup> Tag
<!DOCTYPE html>
<html>
<body>
<select>
<optgroup
label="Swedish Cars">
<option
value="volvo">Volvo</option>
<option
value="saab">Saab</option>
</optgroup>
<optgroup
label="German Cars">
<option
value="mercedes">Mercedes</option>
<option
value="audi">Audi</option>
</optgroup>
</select>
</body>
</html>
<param> Tag
<!DOCTYPE html>
<html>
<body>
<p><b>Note:</b> IE does not support
.wav files. Try to rename the file to "horse.mp3" to test the example
in IE.</p>
<object data="horse.wav">
<param name="autoplay"
value="true">
</object>
</body>
</html>
<pre> Tag
<!DOCTYPE html>
<html>
<body>
<p><b>Note:</b> IE does not support
.wav files. Try to rename the file to "horse.mp3" to test the example
in IE.</p>
<object data="horse.wav">
<param name="autoplay"
value="true">
</object>
</body>
</html>
<progress> Tag
<!DOCTYPE html>
<html>
<body>
Downloading progress:
<progress value="50" max="100">
</progress>
<p><b>Note:</b> The
<progress> tag is not supported in IE and Safari.</p>
</body>
</html>
<s> Tag
<!DOCTYPE html>
<html>
<body>
<p><s>My car is blue.</s></p>
<p>My new car is silver.</p>
</body>
</html>
<strike>
<!DOCTYPE html>
<html>
<body>
<p>Version 2.0 is <strike>not yet
available!</strike> now available!</p>
</body>
</html>
<sub> and <sup> Tags
<!DOCTYPE html>
<html>
<body>
<p>This text contains
<sub>subscript</sub> text.</p>
<p>This text contains
<sup>superscript</sup> text.</p>
</body>
</html>
Class javax.servlet.http.HttpServlet
javax.servlet.GenericServlet |
+----javax.servlet.http.HttpServlet
public abstract class HttpServlet
extends GenericServlet
GenericServlet
base class and provides an framework for handling the HTTP protocol. Because it is an abstract class, servlet writers must subclass it and override at least one method. The methods normally overridden are: -
doGet
, if HTTP GET requests are supported. Overriding thedoGet
method automatically also provides support for the HEAD and conditional GET operations. Where practical, thegetLastModified
method should also be overridden, to facilitate caching the HTTP response data. This improves performance by enabling smarter conditional GET support. -
doPost
, if HTTP POST requests are supported. -
doPut
, if HTTP PUT requests are supported. -
doDelete
, if HTTP DELETE requests are supported. - The lifecycle methods
init
anddestroy
, if the servlet writer needs to manage resources that are held for the lifetime of the servlet. Servlets that do not manage resources do not need to specialize these methods. -
getServletInfo
, to provide descriptive information through a service's administrative interfaces.
service
method is not typically overridden. The service
method, as provided, supports standard HTTP requests by dispatching them to appropriate methods, such as the methods listed above that have the prefix "do". In addition, the service method also supports the HTTP 1.1 protocol's TRACE and OPTIONS methods by dispatching to the doTrace
and doOptions
methods. The doTrace
and doOptions
methods are not typically overridden. JSP Element Type
Directive:
<%@ %>
e.g
page directive
<%@ page import=”abc.* session=””false” %>
A page directive can use up thirteen different attributes
1. import
2. isTheadsafe
3. contentType
4. isELIgnored
5. isErrorPage
6. errorpage
7. language
8. extends
9. session
10.buffer
11. autoFlush
12. info
13. pageEncoding
taglib directive
<%@ taglib tagdir=”/WEB-INF/tags/krrish prefix=””krrish” %>
include directive
<%@ include file=”krrish.html” %>
Declaration:
<%! %>
Scriptlet:
<% %>
Expression:
<%= %>
EL Expression:
$( )
e.g
email:$(application.mail)
Action:
Standard action
<jsp:include page=”abc.jsp”>abc</jsp>
e.g
e.g
- jsp:include
- jsp:param
- jsp:forward
- jsp:plugin
- jsp:fallback
- jsp:getProperty
- jsp:setProperty
- jsp:useBean
Other action
<c:set var=”rate” value=”32”/>
Subscribe to:
Posts (Atom)