Wednesday, 14 March 2018

Simplest way to display Server Time in JSP using js

THE BELOW CODE WORKS ONLY IN JSP :

<html>
<body >
<table width="95%" border="1" cellpadding="1" cellspacing="1" style="margin-left:2; margin-top:10;margin-bottom:10;">
<tr>
<td><strong>Server Time&nbsp;:&nbsp;&nbsp;</strong><label id="timelable"></label></td>
</tr>
<tr>
<td><strong>Client Time&nbsp;:&nbsp;&nbsp;</strong><label id="timeClient"></label></td>
</tr>
</table>
</body>
<script type="text/javascript">
var myVar = setInterval(function(){ myTimer() }, 1000);
var jsVar=  <%=java.util.Calendar.getInstance().getTimeInMillis()%>;
var k = new Date(jsVar);
var timeZoneOffset=<%=java.util.TimeZone.getDefault().getOffset(System.currentTimeMillis())%>;
jsVar=jsVar+timeZoneOffset;

function myTimer() {
jsVar=jsVar+1000;
var d = new Date(jsVar);
var t=d.toUTCString();
document.getElementById("timelable").innerHTML = t;
document.getElementById("timeClient").innerHTML=k;
}
</html>

Friday, 1 July 2016

Struts 2 Questions

1.How Struts 2 validation works?
When the user presses the submit button, Struts 2 will automatically execute the validate method and if any of the if statements listed inside the method are true, Struts 2 will call its addFieldError method. If any errors have been added then Struts 2 will not proceed to call the execute method. Rather the Struts 2 framework will return input as the result of calling the action.
So when validation fails and Struts 2 returns input, the Struts 2 framework will redisplay the view file. Since we used Struts 2 form tags, Struts 2 will automatically add the error messages just above the form filed.
These error messages are the ones we specified in the addFieldError method call. The addFieldError method takes two arguments. The first is the form field name to which the error applies and the second is the error message to display above that form field.

Wednesday, 13 January 2016

BI Publisher

1.How to generate report in PDF directly instead of from HTML to PDF in BI Publisher from Browser?


Hi All,
One solution has been found to generate the report directly in PDF format instead of generating the from html to PDF.

Steps to follow are below.
A.Open the file “_report.xdo” which will be located in the <Report_Name>.xdo  folder EX: DetailedCustomerReportAdhoc.xdo
In file search for “label” in that line change the below attributes.
                        1.From outputFormat="html,pdf,rtf,xlsx,pptx" to outputFormat="pdf"
                        2.From defaultFormat="html" to defaultFormat="pdf"
For Ex:
Change From below line
<template label="test1" url="DetailedCustomerReportAdhoc1.rtf" type="rtf" outputFormat="html,pdf,rtf,xlsx,pptx" defaultFormat="html" locale="en_US" disableMasterTemplate="true" active="true" viewOnline="true"/>
To
            <template label="test1" url="DetailedCustomerReportAdhoc1.rtf" type="rtf" outputFormat="pdf" defaultFormat="pdf" locale="en_US" disableMasterTemplate="true" active="true" viewOnline="true"/>

B.After changing the file Go to catalog select the required report and click on edit as shown below


C.After that click on save button and click View Report as shown below




If still the report is getting viewed directly in HTML. Check the _report.xdo file where the Step 1 done changes are there are not.
If not please follow once again the steps mentioned above.


2.Useful Links for BIP
http://bipublisher.blogspot.in/2012/02/bi-publisher-xdotop-msword-debugging.html


2. How to Set up the Debug On for BIPUBLISHER?
Steps to Turn ON Logging for BI Publisher for Reports debugging

1.Create a folder xdolog and place it under

<Middleware_Home>/user_projects/domains/bifoundation_domain/config/bipublisher

This has to be used in LogDir parameter in step 2.

Note: The above mentioned path is optional .You can create it anywhere

2.Create a file named xdodebug.cfg and place it under

<Middleware_Home>/Oracle_BI1/jdk/jre/lib/

3.Add below listed lines in xdodebug.cfg file

Under Windows

LogLevel=STATEMENT
LogDir=c:\<Middleware_Home>\user_projects\domains\bifoundation_domain\config\bipublisher\xdolog

Under Unix:

LogLevel=STATEMENT
LogDir=<Middleware_Home>/user_projects/domains/bifoundation_domain/config/bipublisher/xdolog

4.Retest the issue

5.Check the files created in the specified LogDir (xdolog) directory.Here you can see XDO.log
6.Remove xdodebug.cfg when finished replicating the issue.


The logging is specifically useful for troubleshooting the Template(RTF/PDF) or Data File(XML file) specific issues. The generated XML file is the actual data file which is run from the MS Word Design Helper Preview mode to narrow down the issue.

3.How to create dynamic query execution in BI Publisher?
In the XDM we have so many DATASETS. Based on some parameters we can have conditional query preparation and execution.

SYNTAX:
                        create sql dataset with following query
                        $if{ (:PARAM == VALUE) }$
                 select 'ravi' as X from dual
            $elsif{(:PARAM == VALUE1 )}$
                 select 'kale' as Z from dual
            $else{
                 select 'TEJ' as Y from dual
            }$
            $endif$

POINTS TO REMEBER:
1. At least One if and one else is mandatory
2.We should not use the double quotes(") or single quotes ('), if the VALUE is string or character.
    EX: a. ravi    --> Correct 
           b. 'ravi'   --> Not Correct
           c. "ravi"  --> Not Correct

EXPLANATION:
While the XDM is exectuing when the above code encounters then the when the inputted parameter is equal value i.e, when the condition satisfies then only the corresponding query executes. Not all the queries executes.

4.How to show Images in generated PDF using RTF Template?
We have 4 solutions. Those solution are available in My Google Drive (BI Publisher/dynamicImages.zip)

Friday, 27 November 2015

PL/SQL

Exception handling
Sample
  EXCEPTION
                     WHEN OTHERS THEN  
                      dbms_output.put_line('we get exception'||sqlcode);
                      dbms_output.put_line('we get exception'||sqlerrm);
                      dbms_output.put_line('we get exception');

Tuesday, 20 October 2015

Connect to Oracle mails through Mobile

Hi friends,

I have seen many of my friends searching for stbeehive and chat configuration.

Following are the few simple steps to enable you to check mail and chat from your mobile with your oracle id:
1.For enabling chat in your android mobile first download "IM+" app from android market. After downloading, open the app and click on Add Account and enter the details as given below:
login: abcd@oracle.com
password: your oracle password
host: stbeehive.oracle.com
Port: 5223
Priority: 5
Resource: IM+ Android
Check "Use old-style SSL"
and then save.
Now you can chat with any of your colleagues at oracle

2.For enabling stbeehive mail in your android mobile first download "K-9 Mail" app from android market. After downloading, open the application and click on add account and following are the details:
email address: abc@oracle.com
Password: your oracle password
click on Manual Setup and click IMAP and enter following details:
username:abc@oracle.com (append oracle.com at the end)
IMAP server: stbeehive.oracle.com
security type: SSL(if available)
Auth type: PLAIN
Port: 993
and click "Next".
You will get another screen asking for Outgoing server settings. Enter the following details:
SMTP server: stbeehive.oracle.com
Security Type: SSL(if available)
Port: 465
Leave other details as it is and click "Next".
Enter the "Account options" as you want and click "Next".

Now you will be able to receive stbeehive mails and even reply back to those mails from your android mobile.

Enjoy!!!

Wednesday, 22 April 2015

Mobile(Tips and Tricks)

For android OS
 If u want your custome ringtones then you have to make a folder in internal sdcard .. Which sholud be named "media" inside it create another folder naming "audio" n inside it "ringtones" .
Name exactly as it has been quoted .. The ringtone you want u can save it in ringtone folder ...

Friday, 10 April 2015

Comparator And Comparable

Comparator vs Comparable
ParameterComparableComparator
Sorting logicSorting logic must be in same class whose objects are being sorted. Hence this is called natural ordering of objectsSorting logic is in separate class. Hence we can write different sorting based on different attributes of objects to be sorted. E.g. Sorting using id,name etc.
ImplementationClass whose objects to be sorted must implement this interface.e.g Country class needs to implement comparable to collection of country object by idClass whose objects to be sorted do not need to implement this interface.Some other class can implement this interface. E.g.-CountrySortByIdComparator class can implement Comparator interface to sort collection of country object by id

Sorting method
int compareTo(Object o1)
This method compares this object with o1 object and returns a integer.Its value has following meaning
1. positive – this object is greater than o1
2. zero – this object equals to o1
3. negative – this object is less than o1
int compare(Object o1,Object o2)
This method compares o1 and o2 objects. and returns a integer.Its value has following meaning.
1. positive – o1 is greater than o2
2. zero – o1 equals to o2
3. negative – o1 is less than o1
Calling methodCollections.sort(List)
Here objects will be sorted on the basis of CompareTo method
Collections.sort(List, Comparator)
Here objects will be sorted on the basis of Compare method in Comparator
PackageJava.lang.ComparableJava.util.Comparator

Print Friendly Version of this pagePrint Get a PDF version of this webpagePDF

Thursday, 5 March 2015

Programs

1.Word count in Java?
public class WordCount{

  public static void main(String[] args) {
    String s = "Count the No of words in the given String. String given is ";
    String array[] = s.split(" ");
    List<String> arrayList = Arrays.asList(array);
    Map<String, Integer> map = new HashMap<String, Integer>();
    for (String string : arrayList) {
      if (map.get(string) == null)
        map.put(string, 1);
      else
        map.put(string, map.get(string) + 1);
    }
    System.out.println("Word Count = " + map);
  }
}
O/P:
Word Count = {of=1, is=1, Count=1, given=2, words=1, String=1, String.=1, the=2, No=1, in=1}

2.How to find the duplicate number in the given integer array?
Conditions : the given string should be in sequence from 1 to n(only one number should be duplicated) .
 public class DuplicateNumber{

  public static void main(String[] args) {
    int[] i = { 1, 2, 3, 4, 5, 6, 6, 7, 8 };
    Arrays.sort(i);
    int sum = 0;
    for (int j = 0; j < i.length; j++) {
      sum = sum + i[j];
    }
    int max = i[i.length - 1];
    int total = max * (max + 1) / 2;
    int miss = total - sum;
    System.out.println(Math.abs(miss));
  }
}
O/P:
The duplicated number is : 6

3. Find the count of letters in the file?
public class CountofLettersString {
  public static void main(String[] args) {
    String str = "CHINNA";
    Map<Character, Integer> wordSet = new HashMap<Character, Integer>();
    Map<Character, Integer> letterCount = new HashMap<Character, Integer>();
    System.out.println("Through String");
    printletterCount(str, letterCount);
    System.out.println("Character" + "-->Count");
    for (Character ch : letterCount.keySet()) {
      System.out.println(ch + "\t--> " + letterCount.get(ch));
    }
    letterCount.clear();
    readthefile(wordSet, letterCount);
    System.out.println("Through File");
    System.out.println("Character" + "-->Count");
    for (Character ch : letterCount.keySet()) {
      System.out.println(ch + "\t--> " + letterCount.get(ch));
    }
  }

  public static void readthefile(Map<Character, Integer> wordSet, Map<Character, Integer> letterCount) {
    Scanner wordFile = null;
    String word;
    try {
      wordFile = new Scanner(new FileReader("words.txt"));
    }
    catch (FileNotFoundException e) {
      e.printStackTrace();
    }
    while (wordFile.hasNext()) {
      word = wordFile.next();
      printletterCount(word, letterCount);
    }
  }

  public static void printletterCount(String str, Map<Character, Integer> letterCount) {
    if (str != null) {
      for (Character c : str.toCharArray()) {
        if (c.isSpaceChar(c)) {
          continue;
        }
        Integer count1 = letterCount.get(c);
        int newCount = (count1 == null ? 1 : count1 + 1);
        letterCount.put(c, newCount);
      }
    }
  }
}
O/P:
Through String
Character-->Count

A    --> 1
C    --> 1
N    --> 2
H    --> 1
I    --> 1
Through File
Character-->Count

A    --> 1
C    --> 1
N    --> 2
H    --> 1
I    --> 1

4.convert string to number without using Parse method?
public class MyStringToNumber {
  public static int convert_String_To_Number(String numStr) {
    char ch[] = numStr.toCharArray();
    int sum = 0;
    int zeroAscii = '0';// Converts the char to int
    for (char c : ch) {
      int tmpAscii = (int) c;// converts the every character of an arry to int
      sum = (sum * 10) + (tmpAscii - zeroAscii);
    }
    return sum;
  }
  public static void main(String[] args) {
    System.out.println("\"3256\" == " + convert_String_To_Number(",jzxcb"));
  }
}


Print Friendly Version of this pagePrint Get a PDF version of this webpagePDF

Thursday, 20 November 2014

Pass By Value In Java



We have
int x= 10;
String y = “Word”;
Employee emp = new Employee();
Now the data store in Stack and Heap how means
Stack                                                                                              Heap
(Stores the primitive data type values )                                  (Stores the referenced objects data)


Now java supports only passbyValue();
Not the passbyReference();
How means
For primitive data types the data stored in Stack as shown above. While accessing the data it send the data as copy of value.
For referenced object related will be store in Heap as shown above. While accessing the data it sends the objects data as copy of reference value.

Diff between copy of value and copy of reference value
EX:
import java.util.ArrayList;
import java.util.List;
public class PassByValue {
  public static void addList(List  l){
    l.add("1");
    l.add("6");
  }
  public static void addInt(int xx){
    xx = 1000;
  }
  public static void main(String[] args) {
            List list = new ArrayList();
            addList(list);
            System.out.println("List Size : "+list.size());
            int x =10;
            addInt(x);
            System.out.println("Integer Value of X : "+x);  
  }
}
O/P:
List Size : 2
Integer Value of X : 10

 

System.out.println(x); it print value as 10 only because the copyofxValue has changed from 10 to 1000. But not the original value of x.

 
 



System.out.println(list.size()); it prints as 2. Because both list and l are referred to the same object reference value i.e, 0X10. So if we change the data structure of list in addList() method that is also reflected in main() method.

Other main Concept is in Strings

String constant pool(SCP)

Before going to this SCP(String Constant Pool) lemme say difference between
1) String s= new String (“hello”);   and
2) String s=”hello”;
In the first case two obects will be created. one in heap and the other in SCP.(s will always refer to heap object but not to SCP)
In the second case only one object will be created in SCP and s will always refer to the object in SCP.
Object creation in SCP is always optional, first JVM checks if there is any obect present with the required content , if exists then will use the same else create new object. i.e SCP do not allow duplicate objects.
GC(garbage collector) is not allowed to enter SCP. But when ever JVM shutdown, automatically SCP area gets flushes out.
The main adv of this approach is memory utilaization will be improved hence the perforamnce improves.(Coz object creation is lil costly in java.)
 
 
Print Friendly Version of this pagePrint Get a PDF version of this webpagePDF

Simplest way to display Server Time in JSP using js

THE BELOW CODE WORKS ONLY IN JSP : <html> <body > <table width="95%" border="1" cellpadding="1...