Performance of Struts
Why are Struts application (1.1 RC) so slow to start using the embedded OC4J server? I have the debug and detail attributes both set to 0 in the web.xml.
I've used tiles and I didn't notice any significant performance hit.
Similar Messages
-
In evaluating JSF's, I put together a simple customer maintenance application of about 10 screens, first using Struts and then again using JSF's, matching the UI exactly. To measure relative performance between these two technologies, I isolated 3 relative static pages from each and ran individual JMeter benchmarks against them (just cycling between these 3 pages over and over). The struts implementation is approximately 5 times faster (measured in pages/sec) over faces. My question is this the same observation most have seen so far (faces vrs struts)? I understand faces is new and will continue to improve. I am using the lastest snap of faces 1_1_01. I welcome any comments.
This is a slow moving thread, but the issue stills seems to be hanging around. I got similar results current technology.
I grabbed the attachments from the original performance bug https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=3 and ran some JMeter tests against the "JSP only" and the JSF versions.
The pages are really simple, the JSP version outputs a page which is visually identical to the JSF page. The table in question had 10 columns and 50 - 200 rows. Not a huge amount of data. I used MyFaces 1.1.3 as the JSF implementation and ran the test in JBoss 4.0.4 GA running on JDK 1.4.2.
Here's the results:
Table Rows Average [ms] Median [ms] Hits / Min Samples
JSF Testcase 50 36 30 1300 5007
JSP Testcase 50 14 10 4030 5001
JSF Testcase 100 56 60 1050 5001
JSP Testcase 100 21 20 2700 5001
JSF Testcase 200 100 100 590 5001
JSP Testcase 200 26 30 2170 5001 This data confirms the discussion original JSF bug. The JSF version started out nearly three times slower than the JSP page. The relative performance of the JSF version degraded to nearly four times slower as table rows were added.
So if you are thinking about adopting JSF you should be aware of the performance hit and make sure that you can architect around the problem or get the performance benchmarks adjusted. Perceived performance is important in real life projects so it's more than a theoretical problem.
I'd also like to know if anybody has ideas or code samples that make JSF perform better? -
BC4J + Struts: Design questions!
OK, I'm wanting to use Struts with BC4J and have a design question for you BC4J users and gurus.
Here's how I think things would work:
1. User requests page
2. Struts ActionServlet calls perform() on Struts ActionForm
3. Struts ActionForm instantiates BC4J AppModule and calls business method
4. BC4J AppModule instantiates necessary BC4J ViewObjects and performs business operations which return data
5. Struts ActionForm receives value objects from BC4J AppModule
6. Struts ActionForm populates Struts FormBean
7. Struts ActionForm forwards to Struts JSP which displays Struts FormBean
I prefixed the components with Struts/BC4J to keep things clear where things belong.
Now, here are my questions:
In step 3, what's the best method of doing this? Do I need to do JNDI lookups every time? What's the performance overhead of this? Anyone have any best-practice code that does this?
Is this the accepted way of doing things? Is there a better way of designing this system?
Thanks!In Step3 you should use the ApplicationModule pooling framework, especially if you are trying to work in stateful mode because the pooling automatically handle the AM activation/passivation.
There are different way to go at it.
If you are using the BC4J custom tag library and have an ApplicationModule tag in your jsp, the pooling is already initialize. By the time your action is trigger you just need to retrieve the am using the application id:
in your jsp:
<jbo:ApplicationModule id="myAM" ... />
in your Action implementation:
HttpContainer container = HttpContainer.getInstanceFromSession(request.getSession());
SessionCookie cookie = container.getSessionCookie("myAM");
ApplicationModule am = null;
if (cookie != null)
am cookie.useApplicationModule();
This AM id can be passed as URL parameter...
If you do have a JSP with an AM tag you need to create the pool with findSessionCookie call.
For more info about AM pooling look at the end of this thread for Steve resources:
http://forums.oracle.com/forums/message.jsp?id=912431&gid=513211
This is what we are currently doing for to provide support for BC4J in Struts for our next release.
Charles. -
How to perform authentification in Struts 1.2
While performing authentification I need also to store user in session object and use it's attributes (not roles and other permission concerned attributes).
Can somebody help in how to write an Action?
In j2ee tutorial there was an example page :
<form action="j_security_check" method=post>
<input type="text" size="15" name="j_username">
<input type="password" size="15" name="j_password">
<input type="submit" value="Submit">
</form>
and I do not understang what to do with itI'm not sure where you get the name from, but if you call request.getHeaderNames() and list all the headers, it might be in there somewhere. I've never actually used that login method, but it's my understanding that you don't have to write any Action, just the login form page. Technically, this has nothing at all to do with Struts.
-
Performance in weblogic 5.1 and struts 1.1
I have problem with lower performance than JSP using Struts 1.1
and Weblogic 5.1
I need help to comment any tips.
Thanks.You haven't provided enough information for us to give you anything but
very general tips. I'd recommend that start by running your benchmark
and analyzing where your application is spending its time.
-- Rob
Min wrote:
I have problem with lower performance than JSP using Struts 1.1
and Weblogic 5.1
I need help to comment any tips.
Thanks. -
How to perform logical comparison using struts
Hi all, I know this is probably not the best forum for a question regarding struts, but am sure most developers here are familiar with it.
how do you implement this using struts logic present or logic no present tags ?
if ((a != null ) && (b != null))
// perform operation
else
// perform altername operation
I am familiar with the stuts logic tags but not sure about the nesting levels to perform this type of operation.
Cheers<logic:present name="XXXXForm" property="a">
<logic:present name="XXXXForm" property="b">
// perform operation
</logic:present>
</logic:present>
<logic:notPresent name="XXXXForm" property="a">
<logic:notPresent name="XXXXForm" property="b">
// perform altername operation
</logic:notPresent>
</logic:notPresent>
/code] -
Output javascript in struts perform()
I would like to output javascript in struts perform() like in servlet.
But I failed to get the message, could you any one give me some ideas?
==========================================================
public class LoginAction extends Action implements Serializable{
public ActionForward perform(ActionMapping actionMapping,
ActionForm actionForm,
HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) {
if(db_password.equalsIgnoreCase("") ){
PrintWriter out = httpServletResponse.getWriter();
out.println("<script language=JavaScript>");
out.println("<!--");
out.println("alert(\"Auth Fail!\");");
out.println("-->");
out.println("<script>");
return actionMapping.findForward("failure");
return actionMapping.findForward("failure");
===========================================================
Ok, let's see, where do I start?
First of all, if your JavaScript is basically static code, even with some variable
substitutions, you shouldn't be trying to output it in Java code. That's what
JSP is for.
Second, and related to the first point, first write your JavaScript in a JSP or
HTML page, and verify whether it works. Your JavaScript syntax looks wrong.
The "script" element should wrap your JavaScript code. Look at some examples
on the web.
Third, and a minor point, if you say you're using the "perform" method, that seems
to imply you're using "old" Struts, version 1.0.2. Version 1.1 was released quite
a while ago, and it's much better.
and finally, you seem to be confused about how server-side Java and JavaScript
are executed. JavaScript is only interpreted and executed in the browser, not
on the server side. You appear to be trying to execute that JavaScript code as
a result of your password verification failure.
"Samuel Hsu" <[email protected]> wrote:
>I would like to output javascript in struts perform() like in servlet.
>But I failed to get the message, could you any one give me some ideas?
>
>==========================================================
>public class LoginAction extends Action implements Serializable{
> public ActionForward perform(ActionMapping actionMapping,
> ActionForm actionForm,
> HttpServletRequest httpServletRequest,
> HttpServletResponse httpServletResponse) {
>
>if(db_password.equalsIgnoreCase("") ){
> PrintWriter out = httpServletResponse.getWriter();
> out.println("<script language=JavaScript></script>");
> out.println("<!--");
> out.println("alert(\"Auth Fail!\");");
> out.println("-->");
> out.println("<script></script>");
>
> return actionMapping.findForward("failure");
> }
>
> return actionMapping.findForward("failure");
>
> }
>}
>
>===========================================================
>
>
-
How to "Performing an Action on Multiple Selected Records" using Struts-JSP
Hi all:
How to do "Performing an Action on Multiple Selected Records" through using Struts/JSP solution that is original MVC/UIX customizing example by Jheadstart.
I know how to reason by analogy through tutorial guide on
Model and Control layer of MVC , but for View layer that is torment to me !
have any idea ?
thanks a lot .Ting Rung,
In the table in the JSP page you add a checkbox like this:
<td class="fixed">
<input type="checkbox" name="multiselect" value="<%=index%>"/>
</td>
This will render a checkbox in each row, with index number of that row as value.
When you submit the page the request contains the multiselect parameter when at least one row has the checkbox checked.
You can get the value of the multiselect parameter by calling sessionData.getRequestParameterValues("multiselect") in your action. The value is a string array containing the index numbers of the rows that have the checkboc checked.
Steven Davelaar,
JHeadstart Team. -
How can I get the context-parm from a web.xml file using struts?
Hello:
I need get the context-param from the web.xml file of my web project using struts. I want configurate the jdbc datasource connection pooling here. For example:
<context-param>
<param-name>datasource</param-name>
<param-value>jdbc/formacion</param-value>
<description>Jdbc datasource</description>
</context-param>
and then from any Action class get this parameter.
Similar using a simple server can be:
/** Initiates new XServlet */
public void init(ServletConfig config) throws ServletException {
for (Enumeration e = config.getInitParameterNames(); e.hasMoreElements();) {
System.out.println(e.nextElement());
super.init(config);
String str = config.getInitParameter("datasource");
System.out.println(str);
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
// res.setContentType( );
System.out.println("Got post request in XServlet");
PrintWriter out = res.getWriter();
out.println("nada");
out.flush();
out.close();
but only this works for init-params, if I use
<servlet>
<servlet-name>MyServlet</servlet-name>
<display-name>MyServlet</display-name>
<servlet-class>myExamples.servlet.MyServlet</servlet-class>
<init-param>
<param-name>datasource</param-name>
<param-value>jdbc/formacion</param-value>
</init-param>
</servlet>
inside my web.xml. I need something similar, but using struts inside the action class for that I can get the context-params and call my database.
Thank youTo get context parameters from your web.xml file you can simply get the ActionServlet object from an implementing action object class. In the perform (or execute) method make the following call.
ServletContext context = getServlet().getServletContext();
String tempContextVar =
context.getInitParameter("<your context param >"); -
Need help with BC4J/Struts application using a Stored Procedure
Hi,
I am doing a proof of concept for a new project using JDeveloper, Struts and BC4J. We want to reuse our Business logic that is currently residing in Oracle Stored Procedures. I previously created a BC4J Entity Object based on a stored procedure Using Oracle Stored Procedures but this stored procedure is a bit different in that it returns a ref cursor as one of the paramters. http://radio.weblogs.com/0118231/stories/2003/03/03/gettingAViewObjectsResultRowsFromARefCursor.html
I tried the above method, but I am having some trouble with it. I keep getting the error ORA-01008: not all variables are bound when I test it using the AppModule tester.
Here is the store procedure definition:
CREATE OR REPLACE PACKAGE pprs_test_wrappers IS
TYPE sn_srch_results IS REF CURSOR;
PROCEDURE sn_srch_main_test
(serial_num_in IN OUT VARCHAR2
,serial_coll_cd_in IN OUT NUMBER
,max_rows_allowed IN OUT NUMBER
,total_rows_selected IN OUT NUMBER
,message_cd_out IN OUT VARCHAR2
,query_results OUT sn_srch_results
END pprs_test_wrappers;
And here is my code:
package pprs;
import java.math.BigDecimal;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import oracle.jbo.JboException;
import oracle.jbo.domain.Number;
import oracle.jbo.server.DBTransaction;
import oracle.jbo.server.ViewObjectImpl;
import oracle.jbo.server.ViewRowImpl;
import oracle.jbo.server.ViewRowSetImpl;
import oracle.jdbc.driver.OracleCallableStatement;
import oracle.jdbc.driver.OracleTypes;
// --- File generated by Oracle Business Components for Java.
public class LienCheckImpl extends ViewObjectImpl
* This is the PLSQL block that we will execute to retrieve the REF CURSOR
private static final String SQL =
"begin ? := pprs_test_wrappers.sn_srch_main_test(?, ?, ?, ?, ?, ?);end;";
public LienCheckImpl() {}
* Overridden framework method.
* Executed when the framework needs to issue the database query for
* the query collection based on this view object. One view object
* can produce many related result sets, each potentially the result
* of different bind variable values. If the rowset in query is involved
* in a framework-coordinated master/detail viewlink, then the params array
* will contain one or more framework-supplied bind parameters. If there
* are any user-supplied bind parameter values, they will PRECEED the
* framework-supplied bind variable values in the params array, and the
* number of user parameters will be indicated by the value of the
* numUserParams argument.
protected void executeQueryForCollection(Object qc,Object[] params,int numUserParams) {
* If there are where-clause params (for example due to a view link)
* they will be in the 'params' array.
* We assume that if some parameter is present, that it is a Deptno
* value to pass as an argument to the stored procedure.
* NOTE: Due to Bug#2828248 I have to cast to BigDecimal for now,
* ---- but this parameter value should be oracle.jbo.domain.Number type.
String serialNumIn = null;
BigDecimal serialCollCdIn = null;
BigDecimal maxRowsAllowed = null;
BigDecimal totalRowsSelected = null;
String messageCdOut = null;
if (params != null) {
serialNumIn = (String)params[0];
serialCollCdIn = (BigDecimal)params[1];
maxRowsAllowed = (BigDecimal)params[2];
totalRowsSelected = (BigDecimal)params[3];
messageCdOut = (String)params[4];
storeNewResultSet(qc,retrieveRefCursor(qc,serialNumIn,
serialCollCdIn,
maxRowsAllowed,
totalRowsSelected,
messageCdOut));
super.executeQueryForCollection(qc, params, numUserParams);
* Overridden framework method.
* Wipe out all traces of a built-in query for this VO
protected void create() {
getViewDef().setQuery(null);
getViewDef().setSelectClause(null);
setQuery(null);
* Overridden framework method.
* The role of this method is to "fetch", populate, and return a single row
* from the datasource by calling createNewRowForCollection() and populating
* its attributes using populateAttributeForRow().
protected ViewRowImpl createRowFromResultSet(Object qc, ResultSet rs) {
* We ignore the JDBC ResultSet passed by the framework (null anyway) and
* use the resultset that we've stored in the query-collection-private
* user data storage
rs = getResultSet(qc);
* Create a new row to populate
ViewRowImpl r = createNewRowForCollection(qc);
try {
* Populate new row by attribute slot number for current row in Result Set
populateAttributeForRow(r,0, nullOrNewNumber(rs.getBigDecimal(1)));
populateAttributeForRow(r,1, nullOrNewNumber(rs.getBigDecimal(2)));
populateAttributeForRow(r,2, rs.getString(3));
populateAttributeForRow(r,3, rs.getString(4));
populateAttributeForRow(r,4, rs.getString(5));
catch (SQLException s) {
throw new JboException(s);
return r;
* Overridden framework method.
* Return true if the datasource has at least one more record to fetch.
protected boolean hasNextForCollection(Object qc) {
ResultSet rs = getResultSet(qc);
boolean nextOne = false;
try {
nextOne = rs.next();
* When were at the end of the result set, mark the query collection
* as "FetchComplete".
if (!nextOne) {
setFetchCompleteForCollection(qc, true);
* Close the result set, we're done with it
rs.close();
catch (SQLException s) {
throw new JboException(s);
return nextOne;
* Overridden framework method.
* The framework gives us a chance to clean up any resources related
* to the datasource when a query collection is done being used.
protected void releaseUserDataForCollection(Object qc, Object rs) {
* Ignore the ResultSet passed in since we've created our own.
* Fetch the ResultSet from the User-Data context instead
ResultSet userDataRS = getResultSet(qc);
if (userDataRS != null) {
try {
userDataRS.close();
catch (SQLException s) {
/* Ignore */
super.releaseUserDataForCollection(qc, rs);
* Return a JDBC ResultSet representing the REF CURSOR return
* value from our stored package function.
private ResultSet retrieveRefCursor(Object qc,
String serialNum,
BigDecimal serialColCd,
BigDecimal maxRows,
BigDecimal totalRows,
String messageCd ) {
CallableStatement st = null;
try {
st = getDBTransaction().createCallableStatement(SQL,DBTransaction.DEFAULT);
* Register the first bind parameter as our return value of type CURSOR
st.registerOutParameter(1,OracleTypes.CURSOR);
* Set the value of the 2nd bind variable to pass id as argument
if (serialNum == null) st.setNull(2,Types.CHAR);
else st.setString(2,serialNum);
if (serialColCd == null) st.setNull(3,Types.NUMERIC);
else st.setBigDecimal(3,serialColCd);
if (maxRows == null) st.setNull(4,Types.NUMERIC);
else st.setBigDecimal(4,maxRows);
if (totalRows == null) st.setNull(5,Types.NUMERIC);
else st.setBigDecimal(5,totalRows);
if (messageCd == null) st.setNull(6,Types.CHAR);
else st.setString(6,messageCd);
st.execute();
ResultSet rs = ((OracleCallableStatement)st).getCursor(1);
* Make this result set use the fetch size from our View Object settings
rs.setFetchSize(getFetchSize());
return rs ;
catch (SQLException s) {
throw new JboException(s);
finally {try {st.close();} catch (SQLException s) {}}
* Store a new result set in the query-collection-private user-data context
private void storeNewResultSet(Object qc, ResultSet rs) {
ResultSet existingRs = getResultSet(qc);
// If this query collection is getting reused, close out any previous rowset
if (existingRs != null) {
try {existingRs.close();} catch (SQLException s) {}
setUserDataForCollection(qc,rs);
hasNextForCollection(qc); // Prime the pump with the first row.
* Retrieve the result set wrapper from the query-collection user-data
private ResultSet getResultSet(Object qc) {
return (ResultSet)getUserDataForCollection(qc);
* Return either null or a new oracle.jbo.domain.Number
private static oracle.jbo.domain.Number nullOrNewNumber(BigDecimal b) {
try {
return b != null ? new oracle.jbo.domain.Number(b) : null;
catch (SQLException s) { }
return null;
I created the view object in expert mode so there is no entity object. Can someone help? I don't have much time left to finish this.
Also, could I have done this from the Entity object instead of the view object by registering the ref cursor OUT parameter in handleStoredProcInsert()?
Thanks
NatalieI was able to get the input parameter by putting the following in my struts actions class
vo.setWhereClauseParam(0,request.getParameter("row0_SerialNum"));
The full code is:
package mypackage2;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import oracle.jbo.html.BC4JContext;
import oracle.jbo.ViewObject;
import oracle.jbo.html.struts11.BC4JUtils;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class LienCheckView1QueryAction extends Action
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
BC4JContext context = BC4JContext.getContext(request);
// Retrieve the view object instance to work with by name
ViewObject vo = context.getApplicationModule().findViewObject("LienCheckView1");
vo.setRangeSize(3);
vo.setIterMode(ViewObject.ITER_MODE_LAST_PAGE_PARTIAL);
// Do any additional VO setup here (e.g. setting bind parameter values)
vo.setWhereClauseParam(0,request.getParameter("row0_SerialNum"));
// default value for serialCollCd 1 is for Motor Vehicles
vo.setWhereClauseParam(1,new oracle.jbo.domain.Number(1));
// Default value for maxRows_allowed
vo.setWhereClauseParam(2,new oracle.jbo.domain.Number(20));
return BC4JUtils.getForwardFromContext(context, mapping);
This doesn't always work properly though. The first time I press the query button, the SerialNum parameter is still null, however if I re-execute the query by pressing the query button again. It will work, and return the rows. I always have to query twice. Also the SerialNum attribute is set to a String in my view object, it is a varchar column in the database, but some serial number I enter give a "Error Message: oracle.jbo.domain.Number ". This happens even though the underlying BC4J is returning values for the query. I also get a "500 Internal Server Error java.lang.ClassCastException: java.lang.String on my View object's code at line 65 which is
if (params.length>1) serialCollCdIn = (BigDecimal)params[1];
This is an input paramter to the oracle stored procedure that defaults to a Number value of 1.
Any idea what the problem is? Here is the full code for my view object:
package mypackage1;
import java.math.BigDecimal;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import oracle.jbo.JboException;
import oracle.jbo.domain.Number;
import oracle.jbo.server.DBTransaction;
import oracle.jbo.server.ViewObjectImpl;
import oracle.jbo.server.ViewRowImpl;
import oracle.jbo.server.ViewRowSetImpl;
import oracle.jdbc.driver.OracleCallableStatement;
import oracle.jdbc.driver.OracleTypes;
// --- File generated by Oracle Business Components for Java.
public class LienCheckViewImpl extends ViewObjectImpl
* This is the PLSQL block that we will execute to retrieve the REF CURSOR
private static final String SQL =
"begin pprs_test_wrappers.sn_srch_main_test(?, ?, ?, ?, ?, ?);end;";
private BigDecimal totalRows = null;
private String messageCd = null;
private BigDecimal serialColCd = null;
private BigDecimal maxRows = null;
public LienCheckViewImpl() {}
* Overridden framework method.
* Executed when the framework needs to issue the database query for
* the query collection based on this view object. One view object
* can produce many related result sets, each potentially the result
* of different bind variable values. If the rowset in query is involved
* in a framework-coordinated master/detail viewlink, then the params array
* will contain one or more framework-supplied bind parameters. If there
* are any user-supplied bind parameter values, they will *PRECEED* the
* framework-supplied bind variable values in the params array, and the
* number of user parameters will be indicated by the value of the
* numUserParams argument.
protected void executeQueryForCollection(Object qc,Object[] params,int numUserParams) {
* If there are where-clause params (for example due to a view link)
* they will be in the 'params' array.
* We assume that if some parameter is present, that it is a Deptno
* value to pass as an argument to the stored procedure.
* NOTE: Due to Bug#2828248 I have to cast to BigDecimal for now,
* ---- but this parameter value should be oracle.jbo.domain.Number type.
String serialNumIn = null;
BigDecimal serialCollCdIn = null;
BigDecimal maxRowsAllowed = null;
BigDecimal totalRowsSelected = null;
String messageCdOut = null;
if (params != null) {
if (params.length>0) serialNumIn = (String)params[0];
if (params.length>1) serialCollCdIn = (BigDecimal)params[1];
if (params.length>2) maxRowsAllowed = (BigDecimal)params[2];
storeNewResultSet(qc,retrieveRefCursor(qc,serialNumIn,
serialCollCdIn,
maxRowsAllowed));
super.executeQueryForCollection(qc, params, numUserParams);
* Overridden framework method.
* Wipe out all traces of a built-in query for this VO
protected void create() {
getViewDef().setQuery(null);
getViewDef().setSelectClause(null);
setQuery(null);
* Overridden framework method.
* The role of this method is to "fetch", populate, and return a single row
* from the datasource by calling createNewRowForCollection() and populating
* its attributes using populateAttributeForRow().
protected ViewRowImpl createRowFromResultSet(Object qc, ResultSet rs) {
* We ignore the JDBC ResultSet passed by the framework (null anyway) and
* use the resultset that we've stored in the query-collection-private
* user data storage
rs = getResultSet(qc);
* Create a new row to populate
ViewRowImpl r = createNewRowForCollection(qc);
try {
* Populate new row by attribute slot number for current row in Result Set
//AddedByRegisNum
populateAttributeForRow(r,0, nullOrNewNumber(rs.getBigDecimal(1)));
System.out.println("AddedByRegisNum :" + rs.getBigDecimal(1));
// OrigRegisNum
populateAttributeForRow(r,1, nullOrNewNumber(rs.getBigDecimal(2)));
System.out.println("OrigRegisNum :" + rs.getBigDecimal(2));
// SerialNum
populateAttributeForRow(r,2, rs.getString(3));
System.out.println("SerialNum :" + rs.getString(3));
// SerialNumDesc
populateAttributeForRow(r,3, rs.getString(4));
System.out.println("SerialNumDesc :" + rs.getString(4));
// FlagExactMatch
populateAttributeForRow(r,4, rs.getString(5));
System.out.println("FlagExactMatch :" + rs.getString(5));
// MessageCd
populateAttributeForRow(r,5, messageCd);
// TotalRows
populateAttributeForRow(r,6, totalRows);
catch (SQLException s) {
throw new JboException(s);
return r;
* Overridden framework method.
* Return true if the datasource has at least one more record to fetch.
protected boolean hasNextForCollection(Object qc) {
ResultSet rs = getResultSet(qc);
boolean nextOne = false;
try {
nextOne = rs.next();
* When were at the end of the result set, mark the query collection
* as "FetchComplete".
if (!nextOne) {
setFetchCompleteForCollection(qc, true);
* Close the result set, we're done with it
rs.close();
catch (SQLException s) {
throw new JboException(s);
return nextOne;
* Overridden framework method.
* The framework gives us a chance to clean up any resources related
* to the datasource when a query collection is done being used.
protected void releaseUserDataForCollection(Object qc, Object rs) {
* Ignore the ResultSet passed in since we've created our own.
* Fetch the ResultSet from the User-Data context instead
ResultSet userDataRS = getResultSet(qc);
if (userDataRS != null) {
try {
userDataRS.close();
catch (SQLException s) {
/* Ignore */
super.releaseUserDataForCollection(qc, rs);
* Overridden framework method
* Return the number of rows that would be returned by executing
* the query implied by the datasource. This gives the developer a
* chance to perform a fast count of the rows that would be retrieved
* if all rows were fetched from the database. In the default implementation
* the framework will perform a SELECT COUNT(*) FROM (...) wrapper query
* to let the database return the count. This count might only be an estimate
* depending on how resource-intensive it would be to actually count the rows.
public long getQueryHitCount(ViewRowSetImpl viewRowSet) {
Object[] params = viewRowSet.getParameters(true);
String serialNumIn = (String)params[0];
BigDecimal serialCollCdIn = (BigDecimal)params[1];
BigDecimal maxRowsAllowed = (BigDecimal)params[2];
CallableStatement st = null;
try {
st = getDBTransaction().createCallableStatement(SQL,DBTransaction.DEFAULT);
* Register the fourth bind parameter as our return value of type NUMERIC
st.registerOutParameter(4,Types.NUMERIC);
* Set the value of the 3 bind variables to pass as arguments
if (serialNumIn == null) st.setNull(1, Types.CHAR);
else st.setString(1,serialNumIn);
if (serialCollCdIn == null) st.setNull(2,Types.NUMERIC);
else st.setBigDecimal(2,serialCollCdIn);
if (maxRowsAllowed == null) st.setNull(3, Types.NUMERIC);
else st.setBigDecimal(3, maxRowsAllowed);
st.execute();
System.out.println("returning value of :" + st.getLong(4));
return st.getLong(4);
catch (SQLException s) {
throw new JboException(s);
finally {try {st.close();} catch (SQLException s) {}}
* Return a JDBC ResultSet representing the REF CURSOR return
* value from our stored package function.
private ResultSet retrieveRefCursor(Object qc,
String serialNum,
BigDecimal serialColCd,
BigDecimal maxRows) {
CallableStatement st = null;
try {
st = getDBTransaction().createCallableStatement(SQL,DBTransaction.DEFAULT);
* Set the value of the bind variables
System.out.println("SerialNumIn :" + serialNum);
if (serialNum == null) st.setNull(1,Types.CHAR);
else st.setString(1,serialNum);
if (serialColCd == null) st.setNull(2,Types.NUMERIC);
else st.setBigDecimal(2,serialColCd);
if (maxRows == null) st.setNull(3,Types.NUMERIC);
else st.setBigDecimal(3,maxRows);
st.registerOutParameter(1, Types.CHAR); // serialNum
st.registerOutParameter(2, Types.NUMERIC); // serialColCd
st.registerOutParameter(3, Types.NUMERIC); // maxRows
st.registerOutParameter(4, Types.NUMERIC); // totalRows
st.registerOutParameter(5, Types.CHAR); // messageCd
* Register the 6th bind parameter as our return value of type CURSOR
st.registerOutParameter(6,OracleTypes.CURSOR);
st.execute();
ResultSet rs = ((OracleCallableStatement)st).getCursor(6);
serialColCd = st.getBigDecimal(2);
System.out.println("SerialColCd= " + serialColCd);
maxRows = st.getBigDecimal(3);
System.out.println("maxRows= " + maxRows);
totalRows = st.getBigDecimal(4);
System.out.println("totalRows= " + totalRows);
messageCd = st.getString(5);
System.out.println("messageCd= " + messageCd);
* Make this result set use the fetch size from our View Object settings
rs.setFetchSize(getFetchSize());
return rs ;
catch (SQLException s) {
throw new JboException(s);
finally {try {st.close();} catch (SQLException s) {}}
* Store a new result set in the query-collection-private user-data context
private void storeNewResultSet(Object qc, ResultSet rs) {
ResultSet existingRs = getResultSet(qc);
// If this query collection is getting reused, close out any previous rowset
if (existingRs != null) {
try {existingRs.close();} catch (SQLException s) {}
setUserDataForCollection(qc,rs);
hasNextForCollection(qc); // Prime the pump with the first row.
* Retrieve the result set wrapper from the query-collection user-data
private ResultSet getResultSet(Object qc) {
return (ResultSet)getUserDataForCollection(qc);
* Return either null or a new oracle.jbo.domain.Number
private static oracle.jbo.domain.Number nullOrNewNumber(BigDecimal b) {
try {
return b != null ? new oracle.jbo.domain.Number(b) : null;
catch (SQLException s) { }
return null;
Natalie -
Struts tiles to create event based loading of tiles on a JSP
Hi All,
I am working on a web app where I am using struts tiles to create my JSPs. I have tiles for header, footer & nav bar.
Now I want to break up my JSP body in multiple tiles. It is required that I insert only one body tile initially, say body1, which contains few hyperlinks. Depending on which link is clicked, I would attach another tile (body2) below the first one. Can any advanced tiles user inform me if it's possible with struts-tiles, & if yes how?
Thanks.Tiles is basically used to overload the jsp pages and reuse them.
In your tiles-defs.xml file:
//Tiles for header, footer and nav bar goes here
//Tiles for body1 and body2 goes here
<definition name="BodyTile" page="/yourPage.jsp">
<put name="body1" value="/blank.jsp" />
<put name="body2" value="/blank.jsp" />
</definition>
<!--Blank jsp is a simple html page without any data into it-->
Now create a customized tile for your module. Mapping has to be done in struts-config.xml.
Notice that the definitions here extend the tile from tiles-defs.xml, i.e. "BodyTile"
<definition name="ActionOneWithBodyOne" extends="BodyTile">
<put name="body1" value="/yourPage1.jsp" />
</definition>
<definition name="ActionTwoWithBodyTwo" extends="BodyTile">
<put name="body1" value="/yourPage1.jsp" />
<put name="body2" value="/yourPage2.jsp" />
</definition>Now when you first load the page forward it to "ActionOneWithBodyOne" and it displays you just your body1.
When ever u click a link on body 1, after performing the action populate the form bean corresponding to yourPage2.jsp and forward the action to "ActionTwoWithBodyTwo".
Hope that helps!!
SirG -
Need help with Berkeley XML DB Performance
We need help with maximizing performance of our use of Berkeley XML DB. I am filling most of the 29 part question as listed by Oracle's BDB team.
Berkeley DB XML Performance Questionnaire
1. Describe the Performance area that you are measuring? What is the
current performance? What are your performance goals you hope to
achieve?
We are measuring the performance while loading a document during
web application startup. It is currently taking 10-12 seconds when
only one user is on the system. We are trying to do some testing to
get the load time when several users are on the system.
We would like the load time to be 5 seconds or less.
2. What Berkeley DB XML Version? Any optional configuration flags
specified? Are you running with any special patches? Please specify?
dbxml 2.4.13. No special patches.
3. What Berkeley DB Version? Any optional configuration flags
specified? Are you running with any special patches? Please Specify.
bdb 4.6.21. No special patches.
4. Processor name, speed and chipset?
Intel Xeon CPU 5150 2.66GHz
5. Operating System and Version?
Red Hat Enterprise Linux Relase 4 Update 6
6. Disk Drive Type and speed?
Don't have that information
7. File System Type? (such as EXT2, NTFS, Reiser)
EXT3
8. Physical Memory Available?
4GB
9. Are you using Replication (HA) with Berkeley DB XML? If so, please
describe the network you are using, and the number of Replica’s.
No
10. Are you using a Remote Filesystem (NFS) ? If so, for which
Berkeley DB XML/DB files?
No
11. What type of mutexes do you have configured? Did you specify
–with-mutex=? Specify what you find inn your config.log, search
for db_cv_mutex?
None. Did not specify -with-mutex during bdb compilation
12. Which API are you using (C++, Java, Perl, PHP, Python, other) ?
Which compiler and version?
Java 1.5
13. If you are using an Application Server or Web Server, please
provide the name and version?
Oracle Appication Server 10.1.3.4.0
14. Please provide your exact Environment Configuration Flags (include
anything specified in you DB_CONFIG file)
Default.
15. Please provide your Container Configuration Flags?
final EnvironmentConfig envConf = new EnvironmentConfig();
envConf.setAllowCreate(true); // If the environment does not
// exist, create it.
envConf.setInitializeCache(true); // Turn on the shared memory
// region.
envConf.setInitializeLocking(true); // Turn on the locking subsystem.
envConf.setInitializeLogging(true); // Turn on the logging subsystem.
envConf.setTransactional(true); // Turn on the transactional
// subsystem.
envConf.setLockDetectMode(LockDetectMode.MINWRITE);
envConf.setThreaded(true);
envConf.setErrorStream(System.err);
envConf.setCacheSize(1024*1024*64);
envConf.setMaxLockers(2000);
envConf.setMaxLocks(2000);
envConf.setMaxLockObjects(2000);
envConf.setTxnMaxActive(200);
envConf.setTxnWriteNoSync(true);
envConf.setMaxMutexes(40000);
16. How many XML Containers do you have? For each one please specify:
One.
1. The Container Configuration Flags
XmlContainerConfig xmlContainerConfig = new XmlContainerConfig();
xmlContainerConfig.setTransactional(true);
xmlContainerConfig.setIndexNodes(true);
xmlContainerConfig.setReadUncommitted(true);
2. How many documents?
Everytime the user logs in, the current xml document is loaded from
a oracle database table and put it in the Berkeley XML DB.
The documents get deleted from XML DB when the Oracle application
server container is stopped.
The number of documents should start with zero initially and it
will grow with every login.
3. What type (node or wholedoc)?
Node
4. Please indicate the minimum, maximum and average size of
documents?
The minimum is about 2MB and the maximum could 20MB. The average
mostly about 5MB.
5. Are you using document data? If so please describe how?
We are using document data only to save changes made
to the application data in a web application. The final save goes
to the relational database. Berkeley XML DB is just used to store
temporary data since going to the relational database for each change
will cause severe performance issues.
17. Please describe the shape of one of your typical documents? Please
do this by sending us a skeleton XML document.
Due to the sensitive nature of the data, I can provide XML schema instead.
18. What is the rate of document insertion/update required or
expected? Are you doing partial node updates (via XmlModify) or
replacing the document?
The document is inserted during user login. Any change made to the application
data grid or other data components gets saved in Berkeley DB. We also have
an automatic save every two minutes. The final save from the application
gets saved in a relational database.
19. What is the query rate required/expected?
Users will not be entering data rapidly. There will be lot of think time
before the users enter/modify data in the web application. This is a pilot
project but when we go live with this application, we will expect 25 users
at the same time.
20. XQuery -- supply some sample queries
1. Please provide the Query Plan
2. Are you using DBXML_INDEX_NODES?
Yes.
3. Display the indices you have defined for the specific query.
XmlIndexSpecification spec = container.getIndexSpecification();
// ids
spec.addIndex("", "id", XmlIndexSpecification.PATH_NODE | XmlIndexSpecification.NODE_ATTRIBUTE | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
spec.addIndex("", "idref", XmlIndexSpecification.PATH_NODE | XmlIndexSpecification.NODE_ATTRIBUTE | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
// index to cover AttributeValue/Description
spec.addIndex("", "Description", XmlIndexSpecification.PATH_EDGE | XmlIndexSpecification.NODE_ELEMENT | XmlIndexSpecification.KEY_SUBSTRING, XmlValue.STRING);
// cover AttributeValue/@value
spec.addIndex("", "value", XmlIndexSpecification.PATH_EDGE | XmlIndexSpecification.NODE_ATTRIBUTE | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
// item attribute values
spec.addIndex("", "type", XmlIndexSpecification.PATH_EDGE | XmlIndexSpecification.NODE_ATTRIBUTE | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
// default index
spec.addDefaultIndex(XmlIndexSpecification.PATH_NODE | XmlIndexSpecification.NODE_ELEMENT | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
spec.addDefaultIndex(XmlIndexSpecification.PATH_NODE | XmlIndexSpecification.NODE_ATTRIBUTE | XmlIndexSpecification.KEY_EQUALITY, XmlValue.STRING);
// save the spec to the container
XmlUpdateContext uc = xmlManager.createUpdateContext();
container.setIndexSpecification(spec, uc);
4. If this is a large query, please consider sending a smaller
query (and query plan) that demonstrates the problem.
21. Are you running with Transactions? If so please provide any
transactions flags you specify with any API calls.
Yes. READ_UNCOMMITED in some and READ_COMMITTED in other transactions.
22. If your application is transactional, are your log files stored on
the same disk as your containers/databases?
Yes.
23. Do you use AUTO_COMMIT?
No.
24. Please list any non-transactional operations performed?
No.
25. How many threads of control are running? How many threads in read
only mode? How many threads are updating?
We use Berkeley XML DB within the context of a struts web application.
Each user logged into the web application will be running a bdb transactoin
within the context of a struts action thread.
26. Please include a paragraph describing the performance measurements
you have made. Please specifically list any Berkeley DB operations
where the performance is currently insufficient.
We are clocking 10-12 seconds of loading a document from dbd when
five users are on the system.
getContainer().getDocument(documentName);
27. What performance level do you hope to achieve?
We would like to get less than 5 seconds when 25 users are on the system.
28. Please send us the output of the following db_stat utility commands
after your application has been running under "normal" load for some
period of time:
% db_stat -h database environment -c
% db_stat -h database environment -l
% db_stat -h database environment -m
% db_stat -h database environment -r
% db_stat -h database environment -t
(These commands require the db_stat utility access a shared database
environment. If your application has a private environment, please
remove the DB_PRIVATE flag used when the environment is created, so
you can obtain these measurements. If removing the DB_PRIVATE flag
is not possible, let us know and we can discuss alternatives with
you.)
If your application has periods of "good" and "bad" performance,
please run the above list of commands several times, during both
good and bad periods, and additionally specify the -Z flags (so
the output of each command isn't cumulative).
When possible, please run basic system performance reporting tools
during the time you are measuring the application's performance.
For example, on UNIX systems, the vmstat and iostat utilities are
good choices.
Will give this information soon.
29. Are there any other significant applications running on this
system? Are you using Berkeley DB outside of Berkeley DB XML?
Please describe the application?
No to the first two questions.
The web application is an online review of test questions. The users
login and then review the items one by one. The relational database
holds the data in xml. During application load, the application
retrieves the xml and then saves it to bdb. While the user
is making changes to the data in the application, it writes those
changes to bdb. Finally when the user hits the SAVE button, the data
gets saved to the relational database. We also have an automatic save
every two minues, which saves bdb xml data and saves it to relational
database.
Thanks,
Madhav
[email protected]Could it be that you simply do not have set up indexes to support your query? If so, you could do some basic testing using the dbxml shell:
milu@colinux:~/xpg > dbxml -h ~/dbenv
Joined existing environment
dbxml> setverbose 7 2
dbxml> open tv.dbxml
dbxml> listIndexes
dbxml> query { collection()[//@date-tip]/*[@chID = ('ard','zdf')] (: example :) }
dbxml> queryplan { collection()[//@date-tip]/*[@chID = ('ard','zdf')] (: example :) }Verbosity will make the engine display some (rather cryptic) information on index usage. I can't remember where the output is explained; my feeling is that "V(...)" means the index is being used (which is good), but that observation may not be accurate. Note that some details in the setVerbose command could differ, as I'm using 2.4.16 while you're using 2.4.13.
Also, take a look at the query plan. You can post it here and some people will be able to diagnose it.
Michael Ludwig -
I am attempting to use the "How to Use the Struts Validator Plug-in with JDeveloper 10g" written by Duncan in a JDeveloper 10.1.3.0.4 application with standard model/ViewController projects. I am using JSP/Struts/ADF technologies.
I have performed the below:
Struts Config:
<form-bean name="surveyDataForm" type="oracle.adf.controller.v2.struts.forms.BindingContainerValidationForm" className="oracle.adf.controller.struts.forms.BindingContainerValidationFormConfig"/>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>
In the validation.xml:
<!DOCTYPE form-validation
PUBLIC "-//Apache Software Foundation//
DTD Commons Validator Rules
Configuration 1.0//EN"
"http://jakarta.apache.org/
commons/dtds/validator_1_0.dtd">
<form-validations>
<formset>
<form name="surveyDataForm">
<field property="EmpName" depends="required">
<arg0 key="survey.name"/>
</field>
<field property="DateOfService" depends="required">
<arg0 key="survey.service.date"/>
</field>
<field property="ReloContractor" depends="required">
<arg0 key="survey.relo.contract"/>
</field>
</form>
</formset>
</form-validations>
And in my JSP, I have:
<script type="text/javascript">
<html:javascript formName="surveyDataForm"/>
</script>
<html:form action="/survey.do" onsubmit="return validateSurveyDataForm(this)">
(The validation-rules.xml was copied from the JDev install jakarta-struts folder).
I can now see the Javascript showing up in my JSP page, but I don't have a method generated for validateSurveyDataForm or any form like this. I didn't think I had to create this. Also, even without the Javascript, the validator is not called because the JBO errors for required are still showing up. The only thing I have not done is included the modelReference in the Form Bean definition in the struts-config.xml. I'm not sure this will work, or even what to populate this with, as the UIModel.xml is replaced by PageDef.xml and DataBindings.cpx changes.
Anyone have any ideas?
ShayOnly have one network; wireless. On it's own, the MacBook can use wifi to surf the net and Apple TV can watch movie previews from Apple via wifi.
It did work about two months ago. I haven't used it since then for home sharing but have used the Apple TV on its own.
I read the Troubleshooting page on Apple Support. It involves turning various things on and off, which I did -
Performance Vows , Requests get lost ..
I am performance tuning my JSP/Struts web-application deployed over jboss.. I have not got success yet.
During performance/load testing of my web application with apache jmeter.
It is OK up to 1400 request per minute..
But if i increase the load , i get following
Issue: from 1800 requests sent to the application only 1283 were processed ,rest of the requests were lost. I reviewed the application logs. It show it received only 1283 requests, and were processed successfully without any database error, or Java heap space error.
hardware configuration(i use Celeron 3.0Ghz , 1 GB RAM) can be an issue , but the requests should not be lost ..
Is there any way to tune this load ?
Does it requires to programatically pool the requests first in a buffer say and than process them . but it will dampen the response time,as this is done by container till now ?
The required target is whopping 15000 requests per minute.
JasdeepThanx for the response BalusC
But how to acheive this target on my development machine..
It might be possible through buffering the requests first such that requests are not lost, then processing them...
Is there any way out that my request are never lost : if my server/application is busy the request are buffered somewhere and are resent when server/application becomes available. ?
Jasdeep -
What is the logic flow in Struts?
My understanding of the logic flow in Struts is as follows, I would love anybody to correct me.
/index.jsp
<logic:redirect forward="Entry" />The above "Entry" value is located in the struts-config.xml under the "global-forwards" section.
struts-config.xml
<global-forwards>
<forward name="Entry" path="/Login.do" /> ... The path from this "forward" entry is then used to locate an 'action' in the same file. The web.xml specifies that actions are mapped using a "*.do" mask, which I have in my web.xml file. Therefore we look for "/Login" as an action.
<action-mappings>
<action path="/Login" forward="/WEB-INF/login.jsp" /> ...Now we forward to the JSP identified and begin sending this to the client. However, we process it as we send it and we locate some more activities to perform.
/login.jsp
<html:form action="/LoginSubmit" focus="username">
<html:text property="username" />
<html:password property="password" />...In the JSP we find an 'html:form' referencing "/LoginSubmit". We look this up in the 'action-mappings' from our struts-config file too.
struts-config.xml
... <action path="/LoginSubmit" type="...LoginSubmitAction" name="loginForm" input="/WEB-INF/login.jsp" validate="true" scope="request" />...We have found the action statement for this JSP form and notice that there is a 'name' applied. This name should match up with a 'form-bean' from our same struts-config file, so we look that up too.
struts-config.xml
<form-beans>
<form-bean name="loginForm" type="...LoginForm" />This final entry identifies a 'form-bean' class that we create for our application. The java class specifies fields for the input items on the form, it can also specify default values and validation to perform.
...LoginForm.java (sorry about including all of this but it does help)
public class LoginForm extends ActionForm {
private String password;
private String username;
public LoginForm()
super();
public String getPassword()
return this.password;
public void setPassword(String password)
this.password = password;
public String getUsername()
return this.username;
public void setUsername(String username)
this.username = username;
public void reset(ActionMapping mapping, HttpServletRequest request)
super.reset(mapping, request);
setPassword(null);
setUsername("murray");
}I run the above and get a form appearing. It initialises "murray" into the username field, and this is displayed, however I get a javascript error trying to process the focus() request. The generated html form does not receive a name, for example:
<form method="post" action="/bookshelf/LoginSubmit.do;jsessionid=6D7525A5B4B4EBCABA71C679B227A510">The fact that the NAME doesn't appear makes me think that something is not linking correctly, or I have missed some important piece of the logic flow. Is there any other important aspect of this logic I have missed.The error is simple. The HTML source from the page includes these code fragments:
<form method="post" action="/bookshelf/LoginSubmit.do">and
<script type="text/javascript">
var focusControl = document.forms["loginForm"].elements["username"];
if (focusControl.type != "hidden" && !focusControl.disabled) {
focusControl.focus();
</script>The Javacript error reported is:
Error: 'document.forms.loginForm.elements' is null or not an object
Maybe you are looking for
-
How to set up new enviroment variables permanently for all users?
Hi. I downloadad Apache Tomcat, and need to set enviromental variables for all users. I tryed setenv commad, but it is not found. for example # JAVA_HOME="/opt/jre1.6.0" Solaris remembers this variable only for one session and I need for all users pe
-
I can't sync my contacts from my iPhone 5 to my computer
Hi, I've just realised that since i've had the iPhone 5, it hasn't been syncing my contacts onto my computer. I thought it was because I didn't have enough backup storage on iCloud so i deleted my backup (which was stupid because now it says I've nev
-
Error :Could not connect to SAP systemSAP_R3_PLM
Hi, I have uploaded the Business Package for projects into portal and assigned the iviews to a user(test_abc)...when iam trying to view the iviews by logging in to "test_abc" iam getting the following error: <b>Could not connect to SAP systemSAP_R3_P
-
[DW-8]Hacer encuesta
Hola a todos: Tengo el siguiente codigo para hacer encuestas //recibo el voto $voto = $_POST["voto"]; //recibo el id de la encuesta $encid = $_POST["encid"]; $servidor="localhost"; $usuario="root"; $password=""; $base="bd"; $SQLid = mysql_connect($se
-
Where to find camera raw update 6.7.0.339
Can someone please tell me where I can download the update 6.7.0.339 for camera raw? I have cs5 and have had an awful time fixing out how to update anything now that I am installing it on my new mac. Thanks,Krista