jo sim

Ranch Hand
+ Follow
since Apr 24, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by jo sim

My current application setup is this

/usr/AppServer/CDev/Sections.ear/sectionSite/all-listings

I would like to read a folder thats in another location on the same box.


/usr/DiffServer/sectionSite/small-site/sports-news

from my JSP I'm doing
<%
currDir= new File("/usr/DiffServer/sectionSite/small-site/sports-news");
for (File dirItem : currDir.listFiles()) {
out.print("items "+dirItem.getName());
}
%>

Ofcourse I get a null pointer. What am I doing wrong and if its possible how do I get the list of files under /sports-news folder?
13 years ago
JSP
so there is no way I can use scriplet in my xpath. can you please give me an example how I should be doing this? I tried doing
<c:set var="Product" value="Product" /> and than I tried
<x:forEach var="n" select="$doc/root/sitemapdetails[sitemaptitle='${Product}']"> but no success
when I try to substitute <%=val%> with just disney it works but the thing is I need to get the title and link at runtime by providing a scriplet like <%=val%>
yes at runtime. I apologize but what is the way to get the value at runtime?
Hi is there a way to find the title and link based on the title provided dynamically?


<% String val="disney"; %>

<c:import url="books.xml" var="url" />
<x:parse xml="${url}" var="doc" />
<x:forEach var="n" select="$doc/books/book[title='<%=val%>']">
<x:out select="$n/title" />

<x:out select="$n/link" />

</x:forEach>
Sorry the output that im looking for is
index 1
C
fan
Title C1linkC1

index 2
C
fan
Title C2
linkC2

index 3
C
pen
Title C3
linkC2
This is my XML

<?xml version="1.0"?>
<root>
<details>
<list>A</list>
<categ/>
<title>Title A1</title>
<link>linkA1</link>
</details>
<details>
<list>A</list>
<categ/>
<title>Title A2</title>
<link>linkA2</link>
</details>
<details>
<list>B</list>
<categ/>
<title>TitleB1</title>
<link>linkB1</link>
</details>
<details>
<list>B</list>
<categ/>
<title>Title B2</title>
<link>linkB2</link>
</details>
<details>
<list>C</list>
<categ>fan</categ>
<title>Title C1</title>
<link>linkC1</link>
</details>
<details>
<list>C</list>
<categ>fan</categ>
<title>Title C2</title>
<link>linkC2</link>
</details>
</details>
<details>
<list>C</list>
<categ>pen</categ>
<title>Title C3</title>
<link>linkC2</link>
</details>
</root>

based on this XML I need to get all the nodes under <details> where <list> is C so for exmaple if the list is C than I need all the nodes and their values where list = C I can do that by providing this in my xpath.

Document doc = db.parse(file.xml);
doc.getDocumentElement().normalize();
XPath xpath = XPathFactory.newInstance().newXPath();
NodeList resultNode = (NodeList)xpath.evaluate("//details[list = 'C']", doc, XPathConstants.NODESET);

for (int i=0; i < resultNode.getLength(); i++){
Node n = resultNode.item(i);
System.out.println("Node Name: " + n.getNodeName());
System.out.println("Node Value: " + n.getChildNodes().item(0).getNodeValue());
}

// resultNode.getLength() gives me 3 which is correct. I need to be able to get the nodename under details for each where list = C

The result for the above Xpath in the statemtnt should be

<list>C</list>
<categ>fan</categ>
<title>Title C1</title>
<link>linkC1</link>
</details>
<details>
<list>C</list>
fan</categ>
Title C2
linkC2

Details for 3
C
pen
Title C3
linkC2
This is the statement I have in my JSP

<%SampleClass sample= new SampleClass(); %>

Here is part of my SampleClass.

HttpServletRequest request = null;
String path = request.getContextPath();

public void createFile() throws IOException{
File f;
f=new File(path+"WEB-INF/test.txt");
if(!f.exists()){
f.createNewFile();

}
}

my jsp is giving me this error

java.lang.NullPointerException
com.SampleClass .<init>(SampleClass.java:32)

can someone tell me what the issue is and how to fix it? I do know that I am not suppose to have request = null but what can I do to initialize it?
Is there a way to add more than one attribute for example
pageContext.setAttribute("fname",f, "lname",l);

<c: out value='${f},${l}'/>

if there is could someone just put a couple of statements.

thanks.
17 years ago
JSP
Is there a way to add more than one attribute for example
pageContext.setAttribute("fname",f, "lname",l);

<c ut value='${f},${l}'/>

if there is could someone just put a couple of statements.

thanks.
17 years ago
Hi I know about overriding, overloading, extending classes. I just dont know the difference between polymorphism and Inheritance.
17 years ago
for some reason it is compiling. but when executing it displays 0 as a value
17 years ago
Yes it compiles just fine. These classes are in 3 different java files
17 years ago
Hi I have three classes Cal, Cal2 and Inheritance5
Cal is parent, Cal2 extends Cal and Inheritance basically tries to find the total.

Problem: When I try to compile and execute my Inheritance5.java program it prints 0 instead of 12 why is that and is there a way for me to execute it without using super statement or adding another constructor in child class that accepts 2 ints? Please help.


public class Cal
{
private int base, height, total;

Cal(){}
Cal(int b, int h)
{
base = b;
height = h;
}
public void setHeight(int num)
{
height = num;
}
public void setBase(int num)
{
base = num;
}
public void getTotal()
{
System.out.println("Area of the rectangle is " + (base*height));
}
}

=====================================================================
public class Cal2 extends Cal{

}

======================================================================
public class Inheritance5{
public static void main(String[] args){
Cal2 areaRectangle = new Cal2(4,3);
areaRectangle.getTotal();
}
}
17 years ago
I am trying to install oracle and toad on mac OS X. has anybody tried toad on OS X or can give me some idea if it works on it and if not what would you recommend?
17 years ago