Setting a WebCenter Maintenance Page

When you shutdown WebCenter, the apache weblogic mod takes over the control of error pages and shows:

Failure of server APACHE bridge:
No backend server available for connection: timed out after 10 seconds or idempotent set to OFF.

Let’s face it that’s not user friendly and needs to be replaced with a nice page.

Solution
You can set a custom error page following the steps below:

*if you haven’t got OHS_HOME, I recommend you set up this environment variable. The path should look similar to the below:
/apps/oracle/product/middleware/Oracle_WT1/instances/instance1/config/OHS/ohs1

First copy your custom html to the server.
Move the files to
$OHS_HOME/htdocs/
For example you have a file called
maintenance.html

Next modify the config file for the weblogic mod
nano $OHS_HOME/mod_wl_ohs.conf
within the Webcenter location add


LOCATION STUFF
ErrorPage http://[hostname]/maintenance.html

Now to test the change, restart OHS. (if you’re in clustered mode run with 1 spaces, 1 OHS only for now)
Stop Spaces.
Go to WebCenter home.
New html maintenance page displays.
Restart spaces in WLS console.
Spaces displays correctly.

Ensure you copy the files/change in every OHS if you’re in a clustered deployment.

——————————————————————————————————————–

You can set up the maintenance page when at the Web server level when the application is down in the App layer. Here is the reference for Oracle HTTP server, same you can do it for any other web server too..!!

You can achieve this by configuring an error page at the WebServer (part of web-tier).

For example, in the case of a Oracle HTTP Server (OHS), you could do the following:

1. Place your maintenance page at /config/OHS//htdocs.

For Example, /config/OHS//htdocs/errorPage500.html

2. Open the OHS httpd.conf located at /config/OHS/ in an editor and search for the string ‘ErrorDocument 403′ which can be seen as commented text. Next to the commented text line, add the below lines for configuring the Error

Pages (500 —> backend server unavailable, 403 —> forbidden request, 404 –> Resource Not available). For the below example, we had 3 html pages errorPage500.html, errorPage403.html and errorPage404.html are deployed in OHS htdocs.

ErrorDocument 500 /errorPage500.html
ErrorDocument 403 /errorPage403.html
ErrorDocument 404 /errorPage404.html

3. Save the changes to the httpd.conf file.

4. Restart OHS server

———————————————————————————————————————-

Maintenance page for weblogic server

In Apache httpd.conf file put the below , replace the /console with proper context root and same with the host and port no.


SetHandler weblogic-handler
WebLogicHost 192.168.50.57
WebLogicPort 7001
ErrorPage /maintain.html

Place your customized maintain.html in the Root directory.

Happy learning with Vinay in techartifact….

Setting Styles & Formula in excel file using Apache POI

Requirement – Setting styles on excel cells

Solutions– You can set FONT,Color, Bold etc.Use cell.setCellStyle(style) method.

Following is code for setting styles

HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("Style example");
<strong> //Example 1 of setting styles in cell</strong>
HSSFFont font = workbook.createFont();
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
font.setFontName(HSSFFont.FONT_ARIAL); 
HSSFCellStyle style = workbook.createCellStyle();
style.setFont(font);
 
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
cell.setCellValue("Setting text in BOLD and in Arial font");
cell.setCellStyle(style);
 
<strong>  //Example 2 of setting styles in cell</strong>
font = workbook.createFont();
font .setItalic(true);  // setting cell value as italic
font setFontHeightInPoints((short) 12);   //setting font height.
font.setColor(HSSFColor.GREEN.index);  // setting color as green
style = workbook.createCellStyle();
style.setFont(font);
 
row = sheet.createRow(1);
cell = row.createCell(0);
cell.setCellValue("Setting text in italic & green");
cell.setCellStyle(style);
 
try {
    FileOutputStream out = new FileOutputStream(new File("C:\\Vinaystyle.xls"));
    workbook.write(out);
    out.close();
    System.out.println("Excel written successfully..");
     
} catch (FileNotFoundException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}


You can also set the background color for the rows as well in sheet

  // Aqua background
CellStyle style = wb.createCellStyle();
style.setFillBackgroundColor(IndexedColors.AQUA.getIndex());
style.setFillPattern(CellStyle.BIG_SPOTS);
row.setRowStyle(style);

Setting Formula in Excel –

    Row row= sheet.createRow(1);
    row.createCell(0).setCellValue(100);
    rpw.createCell(1).setCellValue(200);
    row.createCell(2).setCellValue(300);
    row.createCell(3).setCellFormula("SUM(A1:A4)");
  or 
    cell.setCellFormula("A2*B3*C4")
 

For evaluating formula you can use –

FormulaEvaluator evaluator = 
workbook.getCreationHelper().createFormulaEvaluator(); 

evaluateFormulaCell(Cell cell) will check to see if the supplied cell is a formula cell. If it isn’t, then no changes will be made to it. If it is, then the formula is evaluated. The value for the formula is saved alongside it, to be displayed in excel. The formula remains in the cell, just with a new value.

Happy coding with Vinay in techartifact

Setting the value in Different scope in ADF in programmatic way

Sometime in ADF application we want to set the value in different scope programmatic .How to do that.
Use below code to do that.You can create a variable in any scope and put value in it

 
  ADFContext adfCtx = ADFContext.getCurrent();
       Map appScope = adfCtx.getApplicationScope();
       appScope.put("vinay", "true");

Similarly you can get the value of any variable stored in any variable

 
  ADFContext adfCtx = ADFContext.getCurrent();
       Map appScope = adfCtx.getApplicationScope();
    String appScopeValue=  (String)appScope.get("vinay");