carl jensen

Greenhorn
+ Follow
since Nov 08, 2000
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by carl jensen

Can I create and send a multipart message with a servlet. I have looked throught the O'Reilly Servlets book and see how to receive and process a message, but nothing about creating one. Specifically, I'd like to create and send the multipart message with one servlet and process it with another.
Thanks!
22 years ago
Thanks for the reply. Do you have any idea how I go about exporting and importing this thing?
Thanks-you,
-Carl Jensen
My application was working fine until last week when we moved servers and changed from a Verisign to a self-signed certificate.
Now, I get the following exception:
Exception: javax.net.ssl.SSLException: untrusted server cert chain
This happens when a servlet tries to communicate to another servlet with the following code:
System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");

URL url = null;
HttpURLConnection urlConnection = null;

try {
String postURL = config.get("gateway.posturl.path");
url = new URL(postURL);
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("POST");
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
urlConnection.setUseCaches(false);
urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
printout = new DataOutputStream (urlConnection.getOutputStream());
printout.writeBytes("zapp" + "=" + xml);
printout.flush();
printout.close();
//get the response
urlConnection.connect();
If I try to access the servlet with a web page (bypassing the first servlet), everything is fine.
I am pretty sure that the problem is related to the certificate switch.
Any help would be much appreciated!
Thank-you,
-carl jensen
I have answered my own question. To specify the DTDs location on the hard drive, do the following:
<!DOCTYPE Xmlife SYSTEM "file:///c:/DTDs/TXLife2.4.99.01.dtd">
Thanks for your quick response.
Maybe I should clarify. My xml document (textXML in the code below) does specify the DTD, but I get an exception because the DTD cannot be found. Here is my code:
SAXBuilder builder = new SAXBuilder();
builder.setValidation(true);

// Create the document
StringReader xmlreader = new StringReader(testXML);
Document doc = builder.build(xmlreader);

When I run this code, I get the following exception:
org.jdom.JDOMException: Error on line 0: File "TXLife2.4.99.01.dtd" not found.
So, I guess the question is: How do I make my Java program aware of the location of my DTD?
I am using VAJ for my IDE.
Thanks!
How do I validate XML against a DTD? I don't see how I am supposed to reference the DTD in my java code.
Thanks!
-carl
I am trying to send large messages (~60,000 bytes) over sockets. For some reason, my messages always get truncated at 15,392 or 15,840 bytes. Can anyone help? Here is sample of my code:
public void run()
{
try
{
int bytesAvailable = in.available();
while(bytesAvailable == 0) {
try {
sleep(20);
bytesAvailable = in.available();
}
catch(InterruptedException ie) {
}
}
// Read 8 1-K packets for a total of 8K message
byte[]b = new byte[(1024 * 8)];
int readCount = 0;
int offSet = 0;
StringBuffer sb = new StringBuffer();

while((readCount = in.read(b,0,b.length))!= -1)
{
if(readCount < 8192)
{
sb.append(new String(b,0,readCount));
break;
}
sb.append(new String(b));
}
Thank-you...
23 years ago
I'm sorry, but I guess I'm still not real sure how to do this. Right now, I'm reading bytes into with the following routine
Could you elaborate?
Thank you! I'll give it a shot.
I am trying to use sockets to allow java to communicate to VB (winsock control). The messages are about 32,000 bytes.
The messages seem to be getting truncated at 8192 bytes. How do I read the whole message in?
Please help!

public NetWorkServer (Socket s) throws IOException {
socket = s;
in = socket.getInputStream();
out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())),true);
start();
}
public void run()
{
try
{
int bytesAvailable = in.available();
while(bytesAvailable == 0) {
try {
sleep(20);
bytesAvailable = in.available();
}
catch(InterruptedException ie) {
}
}
char[] messageBytes = new char[bytesAvailable];
for (int i = 0; i < messageBytes.length; i++) {
messageBytes[i] = (char) in.read();
}
message = new String(messageBytes);


My site, www.doginglasses.com/java.html, has a couple of simple examples of servlets that use the JavaMail API that I have made available for download.
Also check out www.webcabaret.com.
23 years ago