pradeep chellappan

Greenhorn
+ Follow
since Oct 20, 2005
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 pradeep chellappan

Hi All,

Thanks a lot for looking into this and for your time.

Junilu - Your questions make perfect sense.
Aaron - Making protected is an option and will work, but need to think about Junilu's questions.
6 years ago
Hi All,
I want to write test case for private method. I am using Powermock-easymock. I know how to mock a private method, but wondering how to write testcase of private method, as they are not accessible from objects created in testclass.

Regards,
Ramanathan c
6 years ago
Hi All,

I have a java method which separately invokes a static method and a private method, something similar to below:

class A{
protected void comboMethod(){
B.staticMethod();
invokePrivateMethod();
}

private void invokePrivateMethod(){
some logic....
}
}

When i write testcase with Powermock-easymock, i can use class level annotation PrepareForTest in the testclass only once. But in the above scenario, i have to write code for both private and static method. With just 1 PrepareForTest annotation, it will not work. Can anybody help me with a suggestion how to fix this.

Regards,
Ramanathan c
6 years ago
Experts,

I have gone through many explanations on internet to understand why constuctors in java does not have return type. But i couldn't get a clear/satisfictory/convincing answer. Can any one please let me know the "exact" reason.

Regards,
Pradeep
8 years ago
Hi,

I am having a facelet say main.xhml, that has 4 tabs on it. The contents of each tab is inturn a facelet which has corresponding backing bean. I am making a webservice call in the backing bean corresponding to 2nd tab and the code is inside a try catch block. If there is an issue with the webservice call, then we catch the exception and below is the code in Catch block:

response.sendRedirect(req.getContextPath() + "/techError.xhtml");


It is redirecting to techError, but it is getting displayed in tab-2 with tab-2 open. When i see the address bar, the url is corresonding to "req.getContextPath() / main.xhtml". I am not getting any exception related to redirection in console either.

Actually, i want to display the techerror page in full screen.

The same approach works fine for tab-1. When some exception happens for tab-1 backing bean, it redirects to techError page and i can see only techError page in full screen, i don't see any tabs.

In Faces- config i have a navigation -rule as below:


<navigation-rule>
<navigation-case>
<from-outcome>error</from-outcome>
<to-view-id>/techError.xhtml</to-view-id>
</navigation-case>
</navigation-rule>

Please let me know if you need futher details for directing me.

Thanks.


9 years ago
JSF
Thanks Mark,

I want to make sure that i get the Application context through the JNDI defined in Context param. This is critical for me , as in my app we have different versions of the similar file with minor changes for various test environements.

So, i want to know how this can be achieved in my servlet, just by passing servletcontext can i get JNDI value which inturns point to the External spring file?

Thanks for your time.
9 years ago
I need to access few Bean files which is outside my Ear file(or application) from a servlet. The front end is HTML. I have in my web.xml the following:

<param-name>contextConfigLocation</param-name>
<param-value>
jndi://java:comp/env/url/ExternalConfig
</param-value>
</context-param>

JNDI mapping is pointing to a spring file in my local machine. I need to get a bean in servlet and display its value. The bean is defined in Spring file as below:

<bean id="uploadLocation" class="java.lang.String" scope="prototype">
<constructor-arg type="java.lang.String">
<value>/opt/temp</value>
</constructor-arg>
</bean>

I need to get the value "/opt/temp" in servlet. Can you please tell me how this can be achieved in a simple servlet that extends HttpServlet.

9 years ago
Hi ,

I am using a Client proprietary MVC framework to build my webapplication.

Issue:

The Http request sent from the client is not hitting the server and i am getting standard 404 File not found Error while clicking the submit button in my launch page. The Url that is generated upon submitting the request from launchpage.html is something like:

http://localhost:9080/<Webapp-Context Root Name>/execute.do?param1=value1¶m2=value2


I have the following in my web.xml and nothing else.

<servlet>
<servlet-name>someservlet</servlet-name>
<servlet-class>dummyservlet</servlet-class> //assume that dummyservlet is the front controller serlvet
<servlet>
<servlet-mapping>
<servlet-name>someservlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

I have cross checked that atleast my WAR structure is fine. My web applicaiton has the following structure

sampleapplicationweb
javasource
webcontent
META-INF
WEB-INF
lib
web.xml
jsps
launchpage.html

I am using IBM RSA6.0 So, websphere is my Application server. I have done many examples like this in the past,but unable to figure out why the request is not hitting the server for this particular one.

Please let me know what could be the reason for this scenario to occur. What have i done wrong.

Thanks in Advance!

raminjavac
11 years ago
Hi All,

I have added JAD plugin into my eclipse and i have a struts project deployed in Tomcat Server. I am able to see the source code of all the files of struts.jar when i press cntrl+Shift
+T. But when i place a breakpoint on any of the class files and debug , the control is not coming to the location where i had placed the break point.
Please let me know how to debug the struts.jar decompiled class files using eclipse.


Regards,
pradeep
Hi All,

I have added JAD plugin into my eclipse and i have a struts project deployed in Tomcat Server. I am able to see the source code of all the files of struts.jar when i press cntrl+Shift
+T. But when i place a breakpoint on any of the class files and debug , the control is not coming to the location where i had placed the break point.
Please let me know how to debug the struts.jar decompiled class files using eclipse.

Regards,
pradeep
11 years ago
Hi All,

I got the problem myself....

i missed out to include <action-mappings>tag in struts-config.xml.

11 years ago
Hi ,

I am getting the following error:

Error: Cannot retrieve mapping for action /Name



Code Snippet:
----------------

index.jsp

<html:form action="Name" name="nameForm" type="example.NameForm">

struts-config.xml

<form-beans>
<form-bean name="nameForm" type="example.NameForm"></form-bean>
</form-beans>

<action path="/Name"
type="example.NameAction"
name="nameForm"
input="/index.jsp"
>
<forward name="success" path="/displayname.jsp" />
<forward name="failure" path="/index.jsp"/>

</action>
Please let me know what mistake i have commited.
11 years ago
Hi All,

I am Beginner in XML parsing world.

Here is my Xml...

<?xml version="1.0" encoding="ISO-8859-1"?>

<MainFolder name="Projectname">
<SubFolder1>Br</SubFolder1>
<SubFolder2>DD</SubFolder2>
</MainFolder>

Here is the program i tried to attempt:

import java.io.IOException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

public class ParseTrial {
public static Document dom ;

public static void main(String args[]){
parseXml();
parseDocument();
}

public static void parseXml(){
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance() ;
try {
DocumentBuilder db = dbf.newDocumentBuilder() ;
try {
dom = db.parse("d:\\sample.xml") ;

} catch (SAXException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
}
public static void parseDocument(){
Element root = dom.getDocumentElement() ;

NodeList nList = root.getElementsByTagName("MainFolder") ;
System.out.println(nList.toString());

int nlistCount = nList.getLength() ;

System.out.println("Nodelist length:"+ nlistCount);
}
}

I am getting the output as "Nodelist length:0"

I was expecting the output as 2 since there are two elements under the element "Mainfolder".

Can somebody please clarify.

Advance Thanks.
Hi Fred,

If i make a change as shown below:

a= null ;
a = parseString(b) ;

Question

1. What will happen to heap memory allocated previously for the string array object a.Let us suppose that 100,000 times heap memory object is allocated.So,what will happen to the memory allocated if i make string array as null.Will that free the memory utilized previously.If not can you please explain.

2. What i am trying to achieve here is to free the memory allocated for the string array[] object somehow.Can i free the memory allocated to the object-obj of type A by using Runtime.gc().Please advise.

3.The pseudo code which i have written is an example of not releasing the memory properly.Do you agree with me?If yes,why?If not Why?

Thanks ,
Pradeep.

Thanks
Pradeep.
13 years ago
Hi,
I have a doubt with respect to Garbage collection.

Let's suppose we have psuedo code that runs 24X7 as follows:
class A{

String[] a ; //Global Variable
String b ;
methodinA() {
a = parseString(b) ;
}

String[] parseString(String str){
String[] strArray = new String[count];
//Some piece of code
returnn strArray;
}

}

class B{
public static void main(String args[]){
A obj = new A() ;
do{
obj.methodinA() ;
}while(<some condition>
}
}

My question is:

1. Will the object-obj be garbage collected only after the program is terminated.

2. Since in the main method i have a do--while loop and will come out only if the condition(do-while condition) is met.Let's suppose that,this do while loop executes 100,000 times before the while condition fails.That means methodinA() is called 100,000 times.
methodinA() will inturn invoke parseString 100,000 times and a string array strarray is assigned 100,000 times to string array a[].Hence,100,000 times global string array is created and memory consumed by this global string array is never released until termination of program.

I am trying to free the memory of the string array a[] before the program terminates,so my my plan is to do the following:



methodinA() {
a= null ;
a = parseString(b) ;
}

Will the above change work.
If i set string array a[] as null,will it clear up the memory in the heap.

3. Is their any other way in which i can force the garbage collection for this example.Please explain.

Regards,
Pradeep
13 years ago