Wednesday 25 November 2015

Oracle ADF - Change of jsessionid after login

Add the following line in your code.

Subject mySubject = Authentication.login(handler);
ServletAuthentication.runAs(mySubject, request);
ServletAuthentication.generateNewSessionID(request);

Monday 19 October 2015

How to handle exception in JSP?

Ans: Friends, There are two ways to handle exception in JSP.

1.) errorPage
2.) isErrorPage

1.) errorPage: In case of error page you have to mention the jsp file name where you want to handle the exception.It means you do want to handle the exception on same page.

Syntax: <%@ page errorPage="sharma.jsp"%>  where sharma.jsp is a another jsp file where you handle your exception.

2.) isErrorPage: It works on value.It has two values true and false.If you use true value it means the page you are mentioning this property will also handle exception code.It will not transfer control to any other page.
Syntax: <%@ page isErrorPage="true"%>

What is entity cache in Oracle ADF?

Ans: To manage the updates of database.If we do some modification at an entity level then it will store in entity cache until we commit into database.So we can perform different task of data before committing into database using entity cache.It also increase query execution time and database performance.

What is View Accessors in Oracle ADF?

Ans: It is a kind of technic to access view object from another view object or entity object.

Sunday 21 June 2015

Oracle ADF : Difference Between .jws, .jpr and .jpx files?

.jws file - To store the workspace's related information

.jpr file - To store the project related information

.jpx file - To contains the information for creating the data models.

Friday 19 June 2015

Oracle Weblogic : Stuck And Hogging Threads

What is Thread?
A thread is a single sequential flow of control within a program.

What is Stuck Thread?
A Stuck Thread is a thread which is processing a request for more than maximum time that you
configured in admin console. 

How to deal with Stuck Thread?
Take multiple thread dumps immediately.
Review thread dumps or from console (managed server > monitoring > threads).
See how many threads got stuck?
If the stuck thread count is increasing or constant?
If constant then if got stuck on same area (application code etc ) or at different places ?
If getting increase then there would be some serious problem and you have to do a quick health check of you application server, database and other integrated technologies wherever your application reaching like ldap server for authentication, some other API’s or web services etc, and in parallel review thread dumps for stuck threads and share same with your developers to analyze quickly.
If you have one, two or few constant stuck  threads and it’s not increasing then you can monitor it for some more time to check if they get clear or not, if not then to clear them you have only option to restart your managed server(s), and its better to restart and clear them before they make further any impact.

What is Hogging Thread?
 A hogging thread is a thread which is taking more than usual time to complete the request and can be declared as Stuck .

How Weblogic determine a thread to declare as hogging?

A thread declared as Stuck if it runs over 600 secs (default configuration which you can increase or decrease from admin console).
There is an internal WebLogic polar which runs every 2 secs (by default 2 secs and can be alter)
It checks for the number of requests completed in last two minutes
Then it check how much times each took to complete
Then it takes the average time of all completed request (completed in last 2 sec)
Then multiply average time with 7, and the value came consider as “usual time to complete the request”
Now weblogic check each current executed thread in last 2 secs and compare with above average time, if for any of the thread it’s above this value then that thread will declare as Hogged thread.
For example –
At a particular moment, total number of completed requests in last two seconds – 4
Total time took by all 4 requests – 16 secs
Req1 took – 5 secs, Req2 took – 3 secs, Req3 took – 7 secs, Req4 took – 1 sec
Average time = 16/4 = 4 secs
7*4 = 28 secs
Now weblogic check all executed threads to see which taking more than 28 secs, if any then that thread(s) declared as Hogged Thread.
Only the thing you can change with respect to hogging threads configuration is Polar time (Stuck Thread Timer Interval parameter)which is 2 secs by default. You can change this polar value to some different value like 4 secs if you want polar to run in every 4 secs instead of 2 secs.





Tuesday 26 May 2015

Oracle ADF: Basic Concepts

What is Auto Submit?
It is related to an input component such as inputText and selectOneChoice or a table select component.When you use with component it is value will be automatically submitted.

What is Partial Submit?
It is related to a command component such as button,command link.The page partially submits when the button or link is clicked.

What is PPR(Partial Page Rendering)?
It is used to dynamically refresh the part of page.It is done with the use of partial triggers.

What is the use of Action Listener?
It is used to when you want execute some logic and to stay on the page itself.

Syntax:
public void yourActionListenerName(ActionEvent actionEvent)
{

}

What is use of Action?
It is used when you want to execute some logic before navigating to another page.

Syntax:
public String yourActionName() 
{
// Add event code here...
       return null;
}

Flow of immediate=true:

For Input component(inputText,selectOneChoice):
Restore View->Apply Request Values->Process Validations->Update Model->Invoke App->Render Response 

For Command component(button,command link):
Restore View->Apply Request Values->Render Response //skip validations part

Tuesday 19 May 2015

Oracle ADF - How to reuse the taskflow of one application into another application.

Steps :
1.) Create a fusion web application let say Rahul_apps1.



2.) Create a bounded taskflow and drop a view on it.



3.) Click on your view and create a hello.jsff page.



4.) Double click the view controller project.In the project properties dialog, click the Deployment section.Create a new deployment profile by clicking the New option.In the archive type select the ADF library jar file as shown below.



5.) Deploy the project using the newly created deployment profile



6.) Create a another application  and go to file system connection in the resource palette
to point to that directory as shown below. Give some connection name and in the directory
path, point to the jar file deployed directory.Select the deployment and say add to the
project as shown below.



7.) Drop taskflow on your .jspx page.



8.) Run your page.

Monday 18 May 2015

How To Apply ADF Skinning In Your Fusion Web Application By Rahul Sharma

What is CSS?

CSS stands for Cascading Style Sheets.Basically it is a style language which is used for defines
the layout of html documents.It covers fonts, colors, margins, lines, height, width, background images, advanced positions and many other things.

Steps to apply CSS in Fusion Web Application(ADF).

1.) Create your Fusion Web Application(ADF).
2.) Create an xml file called trinidad-skins.xml under view-controller WEB-INF and put this below
code.

<?xml version="1.0" encoding="windows-1252" ?>
<skins xmlns="http://myfaces.apache.org/trinidad/skin">
<skin>
<id>lspskin.desktop</id>
<family>sharmaskin</family>   //must be same as you defined in trinidad-config.xml
<extends>blafplus-rich.desktop</extends>
<style-sheet-name>css/my.css</style-sheet-name>
</skin>
</skins>

3.) In trinidad-config.xml, add the below 3rd line.

<?xml version="1.0" encoding="windows-1252"?>
<trinidad-config xmlns="http://myfaces.apache.org/trinidad/config">
<skin-family>sharmaskin</skin-family>
</trinidad-config>

4.) my.css file code.

body
{
background :white ;
}
af|inputText.lspCustomSkin::content  
{
background-color: Fuchsia;
}
af|inputText.lspCustomSkin::label
{
background-color: Orange;
color: Aqua;
}

If you getting any error in you css file then Go to - Tools - Preferences - CSS Editor - Check ADF
Extension Check Box - Press OK.

5.) Test.jspx Page Code.

<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<f:view>
<af:document id="d1">
<af:form id="f1">
<af:inputText label="Rahul Sharma" id="it1" styleClass="lspCustomSkin"/>
</af:form>
</af:document>
</f:view>
</jsp:root>

You want to see the your modify CSS results without restarting the web application.
Go to web.xml file context parameters set this context parameter value true.

org.apache.myfaces.trinidad.CHECK_FILE_MODIFICATION = true.

Now just deploy your application with this parameter and modify your CSS code then press
F5.You can see the changes.








Thursday 14 May 2015

INSTALLATION OF LOGSTASH, ELASTICSEARCH AND KIBANA by Rahul Sharma

In this post, We are going to talk about how to perform log analytic's using Logstash,
Elasticsearch and Kibana.To start with, we will see how to install this software's on
windows.

What is Logstash?

Logstash is a tool for managing events and logs for your application etc.You can use it to
collect logs,parse them, and store them for later user.One of the best features it has is, you
can read the logs in certain formats(e.g. Apache Logs, NGnix Logs, SysLogs etc) and put
them into Elastic Search.

Installation Of Logstash On Windows :

You can download Logstash from this download here url.Here we have downloaded version
logstash-1..4.2.tar.gz. Now unzip this downloaded file at your desired location.

Steps to ready the logstash environment :

1.) Set the java home in environment vaiables and logstash.bat file.
2.) Go to logstash bin directory.

And that's it, logstash is ready to use.

What is Elasticsearch?

Elasticsearch is a standalone database server, written in Java, that takes data in and stores it in a sophisticated format optimized for language based searches. Working with it is convenient as
its main protocol is implemented with HTTP/JSON. Elasticsearch is also easily scalable,
supporting clustering and leader election out of the box.

Installation Of Elasticsearch On Windows :

Download latest Elasticsearch zip file from download here location and unzip it in your suitable directory.

Steps to run the Elasticsearch:

1.) Set the java path in environment vaiables(No needed if already is set).
2.) Go to elasticsearch bin directory type elasticsearch press enter.

This will start the Elasticsearch service.

What is Kibana?

Kibana is a JavaScript library which allows us to create beautiful dashboard reports using elasticsearch data.

Installation Of Kibana On Windows :

Download Kibana 4 from download here url. Just unzip the zip file and save it in folder.Kibana configuration is very easy, simply edit config/kibana.yml to add the elasticsearch url and done.
Open config/kibana.yml and update property elasticsearch_url: "http://localhost:9200".

Steps to run the Kibana:

1.) Set the java path in environment vaiables(No needed if already is set).
2.) Go to kibana bin directory type kibana press enter.

For Kibana GUI open this url http://localhost:5601/

Enjoy!!

Thursday 30 April 2015

Programming In Java.

String Reverse Program In Java.

Code:-
import java.util.Scanner;
class Reverse
{
public static void main(String[] s)
{
Scanner sc=new Scanner(System.in);
String str=sc.nextLine();
for(int i=str.length()-1;i>=0;i--)
{
System.out.print(str.charAt(i));
}
}
}

Palindrome Number Program In Java.

Code:-
import java.util.Scanner;
class Palindrome
{
static int temp,num,rnum=0,digit;
public static void main(String[] s)
{
Scanner sc=new Scanner(System.in);
num=sc.nextInt();
temp=num;
do
{
digit=temp%10;
temp=temp/10;
rnum=rnum*10+digit;
}
while(temp>0);
if(rnum==num)
{
System.out.println("Number is palindrome");
}
else
{
System.out.println("Number is not palindrome");
}
}
}
Armstrong Number Program In Java

Code:-
import java.util.Scanner;
class Armstrong
{
static int temp,num,rnum=0,digit;
public static void main(String[] s)
{
Scanner sc=new Scanner(System.in);
num=sc.nextInt();
temp=num;
do
{
digit=temp%10;
temp=temp/10;
rnum=rnum+digit*digit*digit;
}
while(temp>0);
if(rnum==num)
{
System.out.println("Number is Armstrong:");
}
else
{
System.out.println("Number is not Armstrong:");
}
}
}

Wednesday 29 April 2015

Star Pattern Program in Java

*
* *
* * *
* * * *
* * * * *
* * * * * *

First Way : 
Code : - 
class Pattern
{
           public static void main(String[] s)
{
for(int i=0;i<6;i++)
{
for(int j=0;j<=i;j++)
{
System.out.print("*");
}
System.out.println();
}
}
}

Second Way : 
Code : - 
import java.util.Scanner;
 class Pattern
{
public static void main(String[] s)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number:");
int num = sc.nextInt();
System.out.println("Number is = "+num);
for(int i=0;i<num;i++)
{
for(int j=0;j<=i;j++)
{
System.out.print("*");
}
System.out.println();
}
}
}

* * * * * *
* * * * *
* * * *
* *
*

Code : - 
import java.util.Scanner;
class Pattern
{
public static void main(String[] s)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number:");
int num = sc.nextInt();
System.out.println("Number is = "+num);
for(int i=0;i<num;i++)
{
for(int j=0;j<num-i;j++)
{
System.out.print("*");
}
System.out.println();
}
}
}

               *
            * * *
          * * * * *
        * * * * * * *
      * * * * * * * * *
    * * * * * * * * * * *
 * * * * * * * * * * * * *

Code:-
import java.util.Scanner;
class Pattern
{
public static void main(String[] s)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number:");
int n = sc.nextInt();
for(int i=0;i<n;i=i+2)
{
for(int j=0;j<n-1-i;j++)
{
System.out.print(" ");
}
for(int k=0;k<=i;k++)
{
System.out.print("* ");
}
System.out.println();
}
}
}

         * *
      * * * *
    * * * * * *
  * * * * * * * *
* * * * * * * * * *

Code :-

import java.util.Scanner;
class Pattern
{
public static void main(String[] s)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number:");
int n = sc.nextInt();
for(int i=0;i<n;i=i+2)
{
for(int j=0;j<n-1-i;j++)
{
System.out.print(" ");
}
for(int k=0;k<=1+i;k++)
{
System.out.print("* ");
}
System.out.println();
}
}
}

*
**
***
****
*****
****
***
**
*

import java.util.Scanner;
class Pattern
{
public static void main(String[] s)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number:");
int num = sc.nextInt();
System.out.println("Number is = "+num);
for(int i=0;i<num;i++)
{
for(int j=0;j<=i;j++)
{
System.out.print("*");
}
System.out.println();
}
for(int i=0;i<num;i++)
{
for(int j=0;j<num-i-1;j++)
{
System.out.print("*");
}
System.out.println();
}
}
}
            *
        *  *
    *  *  *
 * *  *  *

Code: -
import java.util.Scanner;
class Pattern
{
public static void main(String[] s)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number:");
int num = sc.nextInt();
System.out.println("Number is = "+num);
for(int i=0;i<num;i++)
{
for(int j=0;j<num-i-1;j++)
{
System.out.print(" ");
}
for(int k=0;k<=i;k++)
{
System.out.print("*");
}
System.out.println();
}
}
}

*  *  *  *  *
    *  *  *  *
       *   *  *
            *  *
                *

Code :-
import java.util.Scanner;
class Pattern
{
public static void main(String[] s)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number:");
int num = sc.nextInt();
System.out.println("Number is = "+num);
for(int i=num;i>0;i--)
{
for(int j=0;j<num-i;j++)
{
System.out.print(" ");
}
for(int k=0;k<=i-1;k++)
{
System.out.print("*");
}
System.out.println();
}
}
}

      *
    ***
   *****
  *******
*********
  *******
   *****
     ***
       *
Code:-

import java.util.Scanner;
 class Pattern
{
public static void main(String[] s)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number:");
int number = sc.nextInt();
for (int i=1; i<=number; i++)
            {
for (int j=0; j<(number-i); j++)
{
                        System.out.print(" ");
}
                  for (int j = 1; j<=i; j++)
{
                        System.out.print("*");
}
                    for (int k=1; k<i; k++)
{
                        System.out.print("*");
}
                                         System.out.println();
                              }
                              for (int i=number-1; i>=1; i--)
                              {
                for (int j=0; j<(number-i); j++)
{
                        System.out.print(" ");
}
                  for (int j = 1; j<=i; j++)
{
                        System.out.print("*");
}
                  for (int k=1; k<i; k++)
{
                        System.out.print("*");
}
                                           System.out.println();
                                 }
}
}