Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum!

Boon Subra

Ranch Hand
+ Follow
since Jul 18, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Boon Subra

Hi,

Please explain the difference in Fine- Grained and Coarse Grained in EJB

with examples if relevant.


Thanks

Bhuvana
Hi,

I have 6 years of experience in Java J2EE programming and certifies as SCJP and SCBCD.

I am planning to take up a certification in UML.

Please provide me the following info?

1. The exact title of the XML certification

2. Time taken to complete the certification

3. Books and resources for the certification.

4. The level of difficulty to take up the exam with the above experience

Thanks,
Boon
Hi ,

I am using the following Log4j properties for 2 applications.
The first 'RF' is rootCategory and 'ASW' is rootLogger

I want RF to log into test-log.txt
And ASW to admin-log.txt

But it is logging both in admin-log.txt.

#### Use two appenders, one to log to console, another to log to a file

log4j.rootCategory=info, stdout, RF
log4j.rootLogger= info, stdout, ASW

#### First appender writes to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

# Pattern to output the caller's file name and line number.

log4j.appender.stdout.layout.ConversionPattern=[%d{ISO8601}]%5p%6.6r[%t]%x(%F:%L) - %m%n


#### Second appender writes to a file
log4j.appender.RF=org.apache.log4j.DailyRollingFileAppender
log4j.appender.RF.DatePattern='.'yyyy-MM-dd

log4j.appender.RF.File=C:/jrpapp1/wrk/log/weblog/test/test-log.txt
log4j.appender.RF.layout=org.apache.log4j.PatternLayout
log4j.appender.RF.layout.ConversionPattern=[%d{ISO8601}]%5p%6.6r[%t]%x(%F:%L) - %m%n

#### Third appender writes to a file
log4j.appender.ASW=org.apache.log4j.DailyRollingFileAppender
log4j.appender.ASW.DatePattern='.'yyyy-MM-dd

log4j.appender.ASW.File=C:/jrpapp1/wrk/log/weblog/admin/admin-log.txt
log4j.appender.ASW.layout=org.apache.log4j.PatternLayout
log4j.appender.ASW.layout.ConversionPattern=[%d{ISO8601}]%5p%6.6r[%t]%x(%F:%L) - %m%n




I am trying to test it the following test program

import org.apache.log4j.Category;
import org.apache.log4j.Logger;
import org.apache.log4j.Priority;

public class TestLog4j {

private static Logger log = Logger.getLogger(TestLog4j.class.getName());
private static Category cat = Category.getInstance(TestLog4j.class.getName());



public void testLog(){

log.info("Just testing ASW INFO");
cat.info("Just testing RF INFO");

}

public static void main(String[] args) {

TestLog4j tLog = new TestLog4j();
tLog.testLog();

}

}


Thanks,
Boon
Hi,

Thanks for the reply. I have the issue only when I use the validation-rules / validation.xml.

Try to help out.



Bhuvana
16 years ago
Hi,

I get the following error when I try to add a client side validation for 3 fields in JSP.

In struts-config.xml

<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 Validation.xml

<formset>
<!-- ASW form Validation-->
<form name="workBenchForm">
<field property="referenceId"
depends="required">
<arg key="workBenchForm.referenceId"/>
</field>
<field property="rawReason"
depends="required">
<arg key="workBenchForm.rawReason"/>
</field>
</form>
</formset>

In JSP

<html:javascript formName="workBenchForm" dynamicJavascript="true" staticJavascript="true" />

The other tlds are in place.

Please help me out

javax.servlet.jsp.JspException: Cannot find message resources under key org.apache.struts.action.MESSAGE
at org.apache.struts.taglib.TagUtils.retrieveMessageResources(Ljavax/servlet/jsp/PageContext;Ljava/lang/String;Z)Lorg/apache/struts/util/MessageResources;(TagUtils.java:1175)
at org.apache.struts.taglib.html.JavascriptValidatorTag.createDynamicJavascript(Lorg/apache/struts/config/ModuleConfig;Lorg/apache/commons/validator/ValidatorResources;Ljava/util/Locale;Lorg/apache/commons/validator/Form Ljava/lang/String;(JavascriptValidatorTag.java:433)
at org.apache.struts.taglib.html.JavascriptValidatorTag.renderJavascript()Ljava/lang/String;(JavascriptValidatorTag.java:393)
at org.apache.struts.taglib.html.JavascriptValidatorTag.doStartTag()I(JavascriptValidatorTag.java:349)
at jsp_servlet._jsp._admin._workbench.__workbench._jspService(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse V(__workbench.java:309)
at weblogic.servlet.jsp.JspBase.service(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse V(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run()Ljava/lang/Object;(ServletStubImpl.java:1072)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;Lweblogic/servlet/internal/FilterChainImpl V(ServletStubImpl.java:465)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse V(ServletStubImpl.java:348)
at weblogic.servlet.internal.RequestDispatcherImpl.forward(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse V(RequestDispatcherImpl.java:322)
at org.apache.struts.action.RequestProcessor.doForward(Ljava/lang/String;Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse V(RequestProcessor.java:1063)
at org.apache.struts.tiles.TilesRequestProcessor.doForward(Ljava/lang/String;Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse V(TilesRequestProcessor.java:263)
at org.apache.struts.action.RequestProcessor.processForwardConfig(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;Lorg/apache/struts/config/ForwardConfig V(RequestProcessor.java:386)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;Lorg/apache/struts/config/ForwardConfig V(TilesRequestProcessor.java:318)
at org.apache.struts.action.RequestProcessor.process(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse V(RequestProcessor.java:229)
at org.apache.struts.action.ActionServlet.process(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse V(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doGet(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse V(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse V(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse V(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run()Ljava/lang/Object;(ServletStubImpl.java:1072)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;Lweblogic/servlet/internal/FilterChainImpl V(ServletStubImpl.java:465)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse V(ServletStubImpl.java:348)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run()Ljava/lang/Object;(WebAppServletContext.java:6981)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Lweblogic/security/subject/AbstractSubject;Ljava/security/PrivilegedAction Ljava/lang/Object;(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Lweblogic/security/acl/internal/AuthenticatedSubject;Lweblogic/security/acl/internal/AuthenticatedSubject;Ljava/security/PrivilegedAction Ljava/lang/Object;(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(Lweblogic/servlet/internal/ServletRequestImpl;Lweblogic/servlet/internal/ServletResponseImpl V(WebAppServletContext.java:3892)
at weblogic.servlet.internal.ServletRequestImpl.execute(Lweblogic/kernel/ExecuteThread V(ServletRequestImpl.java:2766)
at weblogic.kernel.ExecuteThread.execute(Lweblogic/kernel/ExecuteRequest V(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run()V(ExecuteThread.java:183)
at java.lang.Thread.startThreadFromVM(Ljava/lang/Thread V(Unknown Source)

16 years ago
Hi All,

I am in the last week of scjp1.4 preparation. I am appearing on the 23rd instant. I am so nervous. everything seems to be blank.I am working on the mocks.the posts here are boosting my morale.

Pl give me the link for K&B mock exam. Is is free?

Thanks for everybodys support

Cheers,
Boon
Hi

Could please explain Transaction token in Struts

Thanks,

Boon
17 years ago
Hi can anybody help me out.

thanks
Hi,

With the code given above I was able to use XSL. Now I get the output same as the jsp.

My doubt is:

I have a jsp file that generates the xml file with xsl file./

Before that,I need to parse the dynamic jsp file that fetches record from the database.

If i use DOM ,how should I pass the value for the xml file like

Document doc =
domparser.getDocument("c:/stocks/stocks.xml");
traverseTree(doc, out);

In the above example stocks.xml is a dynamic file which is not stored in any location.

The task i want to do is to convert a jsp to PDF using FOP.

I am able to print the jsp file in the form of xml .
The problem is how to parse it dynamically.

It would be helpful if anybody sends me the code.

Thanks
Boon
[ July 25, 2004: Message edited by: Boon Subra ]
Hi ,
Thanks.I am not able to figure out.

I generated a jsp .(A table with 4 columns and 5 data)

I provided a link n it. PDF Version.

I also generated the xml document in the jsp page.
I mean the xml format is in .jsp file and not .xml file.
I try to use the xsl on the generated xml. I cant print the data rather it just prints the table header .

Please help me out.
I am first trying with simple xsl.Later I can change to xsl:fo.
This is my jsp that generate xml format.

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="clientstyle.xsl"?>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>


<%
int i=1;
%>
<TeamReport>
<Files>
<logic:iterate id="uploadfile" name="upfiles">
<download>
<sno>
<%= i++%>
</sno>
<filename>
<bean:write name="uploadfile" property="UPF_filename_mod1" />
</filename>
<filedate>
<bean:write name="uploadfile" property="UPF_filedate" />
</filedate>
<filepage>
<bean:write name="uploadfile" property="UPF_filepage" />
</filepage>
</download>
</logic:iterate>
</Files>
</TeamReport>

If I remove the highlighted line,it generates xml document.
The xsl is as follows.


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www/w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<table border="1" align="center">
<tr bgcolor="#CCCCCC">
<th height="31" width="8%" align="center">
S.No
</th>
<th class="texthead" height="31" width="44%" align="center">
File Name
</th>
<th class="texthead" height="31" width="34%" align="center">
Submit Date
</th>
<th class="texthead" height="31" width="14%" align="center">
Pages
</th>
</tr>
<xsl:for-each select="TeamReport/Files/download">
<tr>
<td><xsl:value-of select="TeamReport/Files/download/sno"/></td>
<td><xsl:value-of select="TeamReport/Files/download/filename"/></td>
<td><xsl:value-of select="TeamReport/Files/download/filedate"/></td>
<td><xsl:value-of select="TeamReport/Files/download/filepage"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


Please help me out.
Thanks.
Boon
Hi sahil,

I also have the same task.This is something like.

I fetch the list of values from the database.for each record it has a checkbox column.

Depending on a particular logic, I should check the checkbox . Later the user can check/ uncheck it while submitting.

Can you please be clear with the codes.
Thanks,
Bhuvana
17 years ago
I tried to solve. Instead of given the relative path I gave the full path name of the directory:

"D:/Tomcat/../../Client_UpFiles"+fileName;

It worked though.


I have another issue.

How do I download those files from a jsp.
How do i do the mapping.

Thanks,
Boon
17 years ago
hi ,
Thanks for the response. Based on the example,I configured this way. The problem is the out put on the Tomcat consile says the file is uploaded in the path . But the file isnt seen anywhere.

Pl. see the code snippet.
public ActionForward execute(ActionMapping actionMapping,ActionForm actionForm,
HttpServletRequest request,
HttpServletResponse response) throws IOException,ServletException
{

HttpSession session = request.getSession();

String insucode = "FMS";
String target= null;
String data= null;

System.out.println("Hello");

UploadFile theFile = (UploadFile) actionForm;

//retrieve the text data
String desc = theFile.getUPF_filedesc();


//retrieve the file representation
FormFile file = theFile.getUPF_fname();

//retrieve the file name
String fileName= file.getFileName();

//retrieve the content type
//String contentType = file.getContentType();


//retrieve the file size
// String size = (file.getFileSize() + " bytes");
System.out.println("Hello1");

String filepath = "/Client_UpFiles/";
System.out.println(filepath);

try {

System.out.println("Hello2");
//retrieve the file data
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream stream = file.getInputStream();

System.out.println("Hello3");
//write the file to the file specified
OutputStream bos = new FileOutputStream(filepath);
int bytesRead = 0;
byte[] buffer = new byte[8192];
while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
bos.write(buffer, 0, bytesRead);
}
bos.close();
data = "The file " +file +" has been written to \"" + filepath + "\"";

//close the stream
stream.close();

}
catch (FileNotFoundException fnfe)
{
System.out.println(fnfe);
System.out.println("fnfe");
return null;

}
catch (IOException ioe)
{
System.out.println(ioe);
System.out.println("ioe");
return null;
}

System.out.println(data);

target = new String("success");
}



struts-config.xml
====================
<controller

maxFileSize="200K"
tempDir="/Client_UpFiles/">
</controller>

Pl help me out.
Thanks,
Boon
17 years ago
Hi,


Please help me out with this strange problem

I have been working on Tomcat 4.0 on a Struts application

This morning I changed to Tomcat 5.0 and try to run the same application;

I throws:

javax.servlet.ServletException:com/fms/portal/Acuserlogin
.
.
.

root cause:java.lang.NoClassDefFoundError: com/fms/portal/Acuserlogin.


Importantly=== I can see the output to be displayed on the tomcat console(when asked to print),but it is not forwarding to the jsp page.

Please help me.

Thanks,
Boon

[ June 30, 2004: Message edited by: Boon Subra ]
[ July 01, 2004: Message edited by: Boon Subra ]
17 years ago
Hi

You can check it by


http://localhost:8080/<app folder name>/servlet/<servlet name>
Hope this helps
Boon
17 years ago