Geet Chaudhary

Greenhorn
+ Follow
since Feb 15, 2010
Merit badge: grant badges
For More
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 Geet Chaudhary

olivier dutranoit wrote:

my jsp is giving error



details?



----------------

public ActionForward fetchListOfDevelopmentAreas(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) {

String regionId = (String) request.getParameter("region");
ArrayList listOfRegions = new ArrayList();
StringTokenizer strTok = new StringTokenizer(regionId, ",");
while (strTok.hasMoreTokens()) {
listOfRegions.add(strTok.nextToken());
}

HashMap tempDAHM = SupporterReportDBOperator.fetchListOfDAForRegion(listOfRegions);
// here tempDAHM contains data : "Heliópolis,Ixcán" (Special character data)
// fetchListOfDAForRegion(listOfRegions) fucntion is working fine , its just getting data from the DB.

// Here when I am printing tempDAHM 's value on console, its converting Heliópolis to Heli≤polis.So I cant even check for special symbol 'ó'.

formResponseForAJAX(response, tempDAHM);

return null;
}


--------------------------------------------------------------------------------------------
public void formResponseForAJAX(HttpServletResponse response, HashMap hmArg) {

response.setContentType("text/xml");
response.setHeader("Pragma", "no-cache");
response.addHeader("Cache-Control", "must-revalidate");
response.addHeader("Cache-Control", "no-cache");
response.addHeader("Cache-Control", "no-store");
response.setDateHeader("Expires", 0);

Map temphmArg = sortByValue(hmArg);
StringBuffer sb = new StringBuffer();
Set tempEntrySet = temphmArg.entrySet();
Iterator itr = tempEntrySet.iterator();
Map.Entry me = null;

if (temphmArg != null) {
sb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
sb.append("<List>");
sb.append("<valid>true</valid>");
String key = null;
String value = null;
for (int i = 0; i < hmArg.size(); i++) {
me = (Map.Entry) itr.next();
key = me.getKey().toString();
value = me.getValue().toString();
sb.append("<Data>");
sb.append("<Id>" + key + "</Id>");
sb.append("<Name>" + value + "</Name >");
sb.append("</Data>");

}
sb.append("</List>");
try {
response.getWriter().write(sb.toString());
} catch (IOException e) {
// return mapping.findForward("errorPage");
}
} else {
sb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
sb.append("<List>");
sb.append("<valid>false</valid>");
sb.append("</List>");
try {
response.getWriter().write(sb.toString());

} catch (IOException e) {

}

}

}

Below is the the jsp code where I will be calling the above java code:

function populateDA() {

regionList = "";
var doc = document.forms[0];
var count = 0;
emptyMultiSelectDropDown(document.getElementById("developmentArea"));

for (var i=0; i<doc.region.length;i++)
{
if (doc.region[i].selected)
{
count++;
if(regionList.length==0)
{
regionList+= doc.region[i].value;
}else {
regionList+= ','+doc.region[i].value;
}
}
}

if((doc.region.selectedIndex==0) && (count >1)){
alert("Please select either All or other values");
return false;
}

if(doc.region.selectedIndex == 0){
return false;
}

var url = "/supporterReports.do?methodName=fetchListOfDevelopmentAreas®ion="
+ regionList;

if (window.XMLHttpRequest) {

testReq = new XMLHttpRequest();
} else if (window.ActiveXObject) {

testReq = new ActiveXObject("Microsoft.XMLHTTP");
}

testReq.open("GET", url, true);

// This line of code -will open & create the request to be sent to the action method
testReq.onreadystatechange = handleHttpResponseDA;

testReq.send(null);
}

//ajax code to fetch DA list
function handleHttpResponseDA() {

if (testReq.readyState == 4) // when the request is ready
{
var xmlDoc = testReq.responseXML;
var validate = xmlDoc.getElementsByTagName("List");

try {
if (validate[0].childNodes[0].childNodes[0].nodeValue == "true") {
var selectBox = document.getElementById("developmentArea");

var selectedIndexValue=selectBox.value;

if (selectBox.options.length > 0) {
for ( var i = selectBox.options.length - 1; i > 0; i--) {
selectBox.remove(i);
}
}

for ( var i = 1; i < validate[0].childNodes.length; i++) {
var Option = document.createElement("OPTION");
Option.text = validate[0].childNodes[i].childNodes[1].childNodes[0].nodeValue;
Option.value = validate[0].childNodes[i].childNodes[0].childNodes[0].nodeValue;
selectBox.options.add(Option);
}

selectBox.value = selectedIndexValue ;

} else {
alert("There seems to be an error fetching. Please try again1.");
}
} catch (err) {
alert("There seems to be an error fetching. Please try again2.");
}
}
}


On execution I am getting alert "There seems to be an error fetching. Please try again2" as an error message.

This happens only when I have special characters in the data.
12 years ago
JSP
Hi,

I am using "<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>" in my jsp.

I have a drop down box in my jsp that contains few special characters also like (Ixcán,Heliópolis,Orobó).
Because of these special characters, my jsp is giving error.

Please let me know what exactly I should use in charset and pageEncoding.
I have tried "<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>" also.
But its also didn't work.

Thanks
12 years ago
JSP
I have a doubt .. why can't we use assertion for public methods ???
I have read somewhere "An assert is inappropriate in public methods because the method guarantees that it will always enforce the argument checks. A public method must check its arguments whether or not assertions are enabled. Further, the assert construct does not throw an exception of the specified type. It can throw only an AssertionError".

So, wont it applicable for private method too ??
I didnt understand the above statement clearly ..
13 years ago
What is the difference between FileSystemResource and ClassPathResource classes.
When to use what.
Please help me out ..
13 years ago
hi,

I am working with a Web Application ( using Web Logic Server).
I am getting Out of Memory Error in Eclipse.
I know how to resolve it in case of standalone java application ( by passing arguments at runtime).

But how do I pass those arguments in my Web App and how do I can check what arguments Am I working on right now ..

Please help me out in this.

Thanks
13 years ago
I have a parent hbm file (CodeDetail.hbm.xml) that contains other joined-subclass in it and also have hbm that calls this (B.hbm.xml) .
Example :


CodeDetail.hbm.xml :-

<class name="com.pcc.services.bdm.model.CodeDetail" table="CD_DTL"
lazy="true" dynamic-insert="true" dynamic-update="false">

<property name="createdTime" type="java.util.Date" update="false"
insert="true" column="creatn_tmstmp" />

<joined-subclass
name="com.pcc.services.bdm.model.AccountReceivableTermsType" table="ar_trms_cd">
<key column="ar_trms_cd" />
</joined-subclass>
</class>


B.hbm.xml :- That calls CodeDetail.hbm.xml using many-to-one mapping.


<many-to-one name="attributeCdDtlCd"
class="com.pcc.services.bdm.model.CodeDetail" outer-join="true"
column="atrbt_cd_dtl_cd" />
<many-to-one name="status"


My doubt is : When we use B.hbm.xml file, it will load all the attributes as well as </joined-subclass> of CodeDetail.hbm.xml file.
But I want to load only the <property name> of CodeDetail.hbm.xml file.

So, is there any option so that I can avoid </joined-subclass> of CodeDetail.hbm.xml file to get loaded in B.hbm.xml .

Many Thanks ...


I have an attribute in my java class named : private List marketPrograms

I need to map this in my xml file.

Below are the statement , we are using to map it

<field name="marketProgram" type="string" collection="arraylist">
<bind-xml name="marketProgram" node="element" location="marketPrograms"/>
</field>


But it is giving error:

If in case we use {collection="collection"} instead of {collection="arraylist"} then also its giving me error


Below is the Error Message:

org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name 'xmlContext' defined in resource loaded through SAX InputSource: Invocati
on of init method failed; nested exception is org.exolab.castor.mapping.MappingE
xception: The method getMarketProgram/isMarketProgram in class com.pcc.services.
vo.search.criteria.AttributesSearchVO accepting/returning object of type class j
ava.util.ArrayList was not found
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1174)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:425)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:251)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:156)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:248)
Truncated. see log file for complete stacktrace

org.exolab.castor.mapping.MappingException: The method getMarketProgram/isMarket
Program in class com.pcc.services.vo.search.criteria.AttributesSearchVO acceptin
g/returning object of type class java.util.ArrayList was not found
at org.exolab.castor.mapping.loader.AbstractMappingLoader.createFieldHan
dler(AbstractMappingLoader.java:776)
at org.exolab.castor.mapping.loader.AbstractMappingLoader.createFieldDes
c(AbstractMappingLoader.java:548)
at org.exolab.castor.xml.XMLMappingLoader.createFieldDesc(XMLMappingLoad
er.java:461)
at org.exolab.castor.mapping.loader.AbstractMappingLoader.createFieldDes
criptors(AbstractMappingLoader.java:408)
at org.exolab.castor.xml.XMLMappingLoader.createClassDescriptor(XMLMappi
ngLoader.java:231)


Please help me out if someone have any idea in this.
Thanks

Ok John,

Thanks a lot.
13 years ago
Hi John,

I know it will work with LinkedHashSet, but I was trying to do the same thing with HashSet also.

Thanks,
sugita
13 years ago
Hi All,

I need to know, how to retrieve the elements of SET in the same order as they were stored.
[I am not talking about Sorting here]

For example if I have a set object as :
Set s1 = new HashSet();
s1.add("C");
s1.add("B");
s1.add("A");

then I need the output as [C,B,A].

As we all know that the order of storage of elements in the SET is not fixed, so in this case output is not sure to be [C,B,A] only.

Kindly help me out .

Thanks
13 years ago

Tapan Thakkar wrote:code i have used is...

List lst = Collections.EMPTY_LIST;
Collection coll1;

coll = (record from table);

System.out.println(coll1);
//it prints whole on console..
similarly two another Collection coll2,coll3...

it also prints record on console..

bt when i try to append then in a single List or Collection it gives error...n says null pointer exception.......

is there any other way to append list...




hi Tapan ,
I have tried the below the code and its working absolutely fine
You can also try it in your code :

List<String> l1 = new ArrayList<String>();
l1.add("1");
l1.add("2");
l1.add("3");
List<String> l2 = new ArrayList<String>();
l2.add("4");
l2.add("5");
l2.add("6");
List<String> l3 = new ArrayList<String>();
l3.addAll(l1);
l3.addAll(l2);
System.out.println("Third: " + l3);

Its displaying output " Third: [1, 2, 3, 4, 5, 6] " on the console.

Thanks
14 years ago