Wednesday, November 26, 2014

Define Error page in Java web App



Page which will display the Error detail : ErrorPage.jsp

<%@ page isErrorPage=”true” %>
<html>
<body>
<strong>I am Error Page.</strong><br>
Error is : ${pageContext.exception}<br>
</body>
</html>

Page which will cause Error : Hello.jsp

<%@ page errorPage=”ErrorPage.jsp” %>
<html>
<body>
<%=1/0%>
</body>
</html>

Web.xml

<error-page>
          <error-code>404</error-code>
           <location>/jsp/ErrorPage.jsp</location>
</error-page>

<error-page>
          <error-code>java.lang.ArithMeticException</error-code>
           <location>/jsp/ErrorPage.jsp</location>
</error-page>

How to define Error Page in web.xml


Exception Based

<error-page>
<exception-type>java.lang.ArithmeticException</exception-type>
<location>/ExceptionError.jsp</location>
</error-page>

HTTP status code based 

<error-page>
<error-code>404</error-code>
<location>/NotFound.jsp</location>
</error-page>

Friday, November 21, 2014

RADIUS protocol's one line Question/Answer

RADIUS : Remote Authentication Dial In User Service

RADIUS RFC'S : 2865, 2866

0)  Radius is Stateless protocol, Extensible protocol

1) Radius supports protocol for Authentication are : PAP,CHAP,PPP,UNIX-LOGIN

2) Radius Authentication port : 1812

3) Radius Accounting Port : 1813

4) Radius uses UDP

5) Radius Packet Format

6) Code : 1 Octet,   Identifier : 1 Octet,  Length : 2 Octet, Authenticator : 16 Octet

7) Length : Min 20 and Max 4096

8) Radius Attributes
   
CodeAttributes
1User-Name
2User-Password
3CHAP-Password
4NAS-IP-Address
5NAS-Port
6Service-Type
7Framed-Protocol
8Framed-IP-Address
9Framed-IP-Netmask
10Framed-Routing
11Filter-Id
12Framed-MTU
13Framed-Compression
14Login-IP-Host
15Login-Service
16Login-TCP-Port
17(unassigned)
18Reply-Message
19Callback-Number
20Callback-Id
21(unassigned)
22Framed-Route
CodeAttributes
23Framed-IPX-Network
24State
25Class
26Vendor-Specific
27Session-Timeout
28Idle-Timeout
29Termination-Action
30Called-Station-Id
31Calling-Station-Id
32NAS-Identifier
33Proxy-State
34Login-LAT-Service
35Login-LAT-Node 3
36Login-LAT-Group
37Framed-AppleTalk-Link
38Framed-AppleTalk-Network
39Framed-AppleTalk-Zone
40-59(reserved for accounting)
60CHAP-Challenge
61NAS-Port-Type
62Port-Limit
63Login-LAT-Port

9) Diameter Protocol is double than Radius

10) Diameter works on TCP or SCTP protocol

11) Diameter uses Transport level security IPSEC , TLS




Wednesday, November 19, 2014

Include directive vs jsp:include action


Include directive

include directive should be use to include the static contents
which is not getting changed frequently.

It includes the content at the translation time

example
<%@include file="/jsp/core/includes/common/Footer.jsp" %>

<jsp:include> action tag

include action tag is used to include the content which is getting changeg frequently

it includes the content at the runtime

example
<jsp:include page="/jsp/data/dynamic.jsp"/>

Tuesday, November 18, 2014

HTTP Status code Range


1) 100 to 199 (Informational)

This range include the Informational codes about the kind of action client should use or respond

2) 200 to 299 (Request success)

This range include the success codes that indicates the success of the request

3) 300 to 399 (Request File is moved)

This range include the code to indicate that the particular document/file location is moved to another location

4) 400 to 499 (Client side Error)

This range codes indicates the error generated by the client side

5) 500 to 599 (Server side Error)

This range codes indicates the error generated by the server side

How to use

To set the status code one should  use the predefined constants for the respective status code using the method :  response.setStatus(response.SC_ABC_XYZ);


Status Code
Purpose
100-199
Informational
200-299
Request was successful
300-399
Request file has moved.
400-499
Client error
 500-599
Server error.



Some Status Code with their Short Meaning

100 : Continue

200 : OK
202 : Accepted
204 : No Content
205 : Reset Content

301 : Moved Permanentely
302 : Found
303 : See Other
304 : Not Modified


400 : Bad Request
: Bad syntax of the request

401 : Unauthorized
: client tries to access the password protected resource, 

403 : Forbidden
: server refuse to supply the requested resource

404 : Not Found
: when the requested resource is not found on the server.

405 : Method Not Allowed
: put,trace,delete,options if server doesnt support the method requested.

415 : Unsupported Media Type
: request contain the document that the server doesnt know how to handle.

417 : Expectation Failed
: request ask to process some document with 100 code in header, in this request response
 server can respond with code 417


500 : Internal Server Error
: When Server is Confused.

501 : Not Implemented
: doesnt support the functionality to fullfill the request.

503 : Service Unavailable
: When server is not able to fullfill the request service. because of overloading or maintenance or etc




How to Include Header and Footer in all Jsp files Dynamically


Include following tag in your web.xml file with your files proper path
it will include Header.jsp in header of all jsp file and Footer.jsp in footer of all the jsp files

<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<include-prelude>/view/commons/Header.jsp</include-prelude>
<include-coda>/view/commons/Footer.jsp</include-coda>
</jsp-property-group>
</jsp-config>

Sunday, November 16, 2014

STRUTS2 Wildcard Congiguration in struts.xml file

Wildcard configuration in struts.xml file

<action name="*/*"  class="com.raj.rk.controller.{1}.{1}CTRL" method="{2}" >                                     
            <result name="create">/view/{1}/{1}Create.jsp</result>
            <result name="update">/view/{1}/{1}Update.jsp</result>                       
            <result name="view">/view/{1}/{1}View.jsp</result>
            <result name="list">/view/{1}/{1}Search.jsp</result>
</action>

Explanation

name = */*  
If the request comes for action policy/create.action, then the {1} will be policy and {2} will be create. so this both values will be mapped into the respected position in the action tag. and it will work accordingly.

Controller
In this policy/create call the controller called will be PolicyCTRL.java
and the method called will be create() inside the the PolicyCTRL.java class

Result
and the result file called will be /view/policy/PolicyCreate.jsp

Scrum and Scrum master

Scrum  Scrum is a framework which helps a team to work together.  It is like a rugby team (the scrum name comes from rugby game). Scrum enco...