Helmut Lerch

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

Recent posts by Helmut Lerch

After some serching I found the answer on my on:

<c:import url="file.xml" var="xml"/>
<x:parse xml="${xml}" var="doc" />
<x:out select="$doc/*[local-name()='root' and namespace-uri()='somenamespace']/*[local-name()='item' and namespace-uri()='somenamespace']" />

Helmut
20 years ago
JSP
I am not sure, if I understand your question.

But if you want to import data from an xml file in your jsp Page you can use
for example jstl:

http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSTL5.html#wp63716
or
http://www.javaranch.com/newsletter/200311/Nov2003Newsletter-JSTL-Excerpt.html

Helmut
20 years ago
JSP
Maybe you can post some code to explain where you declare what/want to access what?

Helmut
20 years ago
Hy all,

I have an xml-file with a namespace declaration. For example:

--file.xml--
<?xml version="1.0"?>
<sn:root xmlns:sn="somenamespace"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="somenamespace somenamespace.xsd">
<sn:item>Some Text</sn:item>
</sn:root>

How can I parse and access the content of this file with jsp? The following code produces only an output if I omit the xmlns declaration in "file.xml".

--file.jsp---
<c:import url="file.xml" var="xml"/>
<x :parse xml="${xml}" var="doc" />
<x ut select="$doc/root/item" />

Thanks very much for helping,
Helmut
[ November 07, 2004: Message edited by: Helmut Lerch ]
20 years ago
JSP

Originally posted by Mohan K:

char c = 0xffff ; // your input stream
long l = 0x00ff & c ;
System.out.println("l = c & 0x00ff: l = " + l); //255


Thanks nice idea. I will think about it although I have to do the conversation between long and char somtimes twice because I need both bytes separatly.
Eamonn: you can assign 0xFF to a byte without loss its just not "interpreted" as 255, its interpreted as -1. Take a look at the reply of Dave Vick, he explain it very well.
Thanks Heli
23 years ago

Originally posted by Dave Vick:

hope it helps


Thanks for your detailed explanation.
Heli
23 years ago
Hi,

Originally posted by wai meng:
Hi All,
Need some help here... I am returning a date field from an oracle query and it returns in the format:
1958-06-11 00:00:00.0
is there a way in java to convert this into 11/06/1958?
Thanks a million!
Cheers,
Wai Meng


Take a look at SimpleDateFormat.parse(String) and SimpleDateFormat.format(Date).
(http://java.sun.com/j2se/1.4/docs/api/java/text/SimpleDateFormat.html)
Heli
23 years ago
Hi,

Originally posted by Joey Tran:
I need to retrieve value of a final static string in an interface. I don't know the interface name till run time. I cannot load the interface because no class implements the interface. Would you give me some suggestion?
Thanks


I suppose the following code:
<pre>
public interface Inter {
public static String str = "String";
}
public class JustMain {
public static void main(String args[]) {
//retrieving the String
System.out.println(Inter.str);
System.exit(0);
}
}
</pre>
If I supposed wrong forget everything .
Heli

[This message has been edited by Helmut Lerch (edited October 04, 2001).]
23 years ago

Originally posted by Dave Vick:
If I understand correctly you're trying to take the 0xFF value and put it into a byte then later be able to put the byte into a long and get the 0xFF value back out.


Thanks for answering.
The 0xFF value is just an example. It could be any of the other 255 Values of a byte. I am reading a file with read(byte[] b, int off, int len) and I want to put for example two of this bytes in a long. (one in the bits 0 to 7 an the next one in the bits 8 to 15). But I am struggling even with just assigning a byte to a long.

Originally posted by Dave Vick:
All of the other bits are lost and can't be reclaimed, that's why you couldn't convert it back and get the value 255 after turning it into a long.


I thought I don't loose any bits if I assign 0xff to a byte, so conversion back to long should be possible without loss. Am I wrong? A byte has eight bits, 0xff has eight bits set to 1. Of course I just "see" -1 instead of 255 because byte is defined as signed.
Thanks Heli
23 years ago
Hi,

Originally posted by Mikael Jonasson:
Try casting it.
/Mike


some things I have tried:
<pre>
public class AssignByteLong {
public static void main(String[] args) {
byte b = (byte)0xFF;
long l = 0xFF;
System.out.println("b = 0xFF: b = " + b); // -1
System.out.println("l = 0xFF: l = " + l); // 255
l = 0;
l = b;
System.out.println("l = b: l = " + l); // -1
l = 0;
l = (b);
System.out.println("l = (b): l = " + l); // -1
l = 0;
l = ((long)b);
System.out.println("l = ((long)b): l = " + l); // -1
l = 0;
l |= b;
System.out.println("l |= b: l = " + l); // -1
l = 0;
l = (b << 1);<br /> System.out.println("l = (b << 1): l = " + l); //-2<br /> l = 0;<br /> l = (b >> 1);<br /> System.out.println("l = (b >> 1): l = " + l); //-1
l = 0;
l = (b < 0 ? ((b & 0x7F) | 0x80) : b);
System.out.println("l = ((b & 0x7F) | 0x80): l = " + l); //255
}
}
</pre>
So I have a solution but I think there should be a "better", easier one.
Thanks
Heli
23 years ago
Hi,

Originally posted by Uma Viswanathan:
I tried to execute the program...but i am getting ClassCastException.
Exception in thread "main" java.lang.ClassCastException: java.lang.String
at com.sun.java.util.collections.TreeMap.compare(TreeMap.java:994)


Take a look at http://java.sun.com/docs/books/tutorial/collections/problems/index.html.
Heli

[This message has been edited by Helmut Lerch (edited October 02, 2001).]
23 years ago
Hi,
I' m not very used to bit arithmetic. I need to assign a byte to a long.
long l = 0xFF; //255
byte b = 0xFF;
l = b //-1
I know it's something about two's complement and signed/unsigned,
but I don't know how to solve.
Thanks for help
Helmut
23 years ago
Thanks for answering.

Originally posted by Nathan Pruett:
From what I see two things could be wrong...


  • img.jpg doesn't really exist where you say it does... Java will try to load your image, but if it's not there, a null image reference will be used with no complaints.


  • -Nate


I thought there will be sure some Exception if this happens.
Again thanks
Heli
23 years ago

Originally posted by Elizabeth Luckose:
Hi
I am working on a chat program. I am appending the messages to a TextArea in an applet. I want to show the messages in different colors as they are appended to the text area. If I call setForeground for the textarea, the messages already appended to the textarea are changed to the new color. How can I prevent this and show only the message that is appended after calling setForeground()be shown in that color? Is there any other way?
Please help...urgent
Thanks,
Elizabeth


Since you mention TextArea I assume you are using AWT. You can't color parts of the Text differently within TextArea. You have to use swing or write your own component.
Heli
23 years ago
Hi,
what am i missing? Assume the following code for displaying an Image in a frame.
<pre>
import java.awt.*;
public class ImageFrame extends FrameWithClose {
Image img;
public ImageFrame() {
img = Toolkit.getDefaultToolkit().getImage("c:\\img.jpg");
}
public void paint(Graphics g) {
g.drawImage(img, 0, 0, this);
}
public static void main(String [] args) {
ImageFrame f = new ImageFrame();
f.setSize(640, 480);
f.repaint();
f.setVisible(true);
}
}
</pre>
But there is nothing displayed. What I am doing wrong.
Thanks for help
Heli
23 years ago