comp.lang.java.programmer
http://groups-beta.google.com/group/comp.lang.java.programmer
[EMAIL PROTECTED]

Today's topics:

* returning a subclass through an interface - 3 messages, 3 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b62cd9cf6edaa6c4
* CachedRowSet update problem - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cdde2e9b6a8fd68f
* Remove punctuation from String? - 5 messages, 4 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/397f172e95f24d78
* RegEx partial matching - 4 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/14069fafc93c4493
* test javamail file - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/49e12ffa7e150d55
* Authenticator Question - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7eaecb4ca1f08577
* EnableSerializationFocusListener usage? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8e36f3f834dd317
* How to handle attachments with axis - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1052ce4ea95bafd7
* Multi-threaded access to a file on disk - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fc88e19bbf867357
* cannot resolve symbol errors - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/321eb384d3f247e0
* Struts iterate indexed nested objects - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4308a477a108f808
* Http to port different than 80? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/83c9369f58ffcd00
* currentThread, getContextClassLoader and get resource - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e4c0429549cea577
* Need as much help as possible - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7c8e64b34d7154d8
  
==========================================================================
TOPIC: returning a subclass through an interface
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b62cd9cf6edaa6c4
==========================================================================

== 1 of 3 ==
Date:   Thurs,   Nov 11 2004 5:35 am
From: "John C. Bollinger" <[EMAIL PROTECTED]> 

Andy Fish wrote:
> OK, here's a sample. The API returns a PersonDTO (Data Transfer Object). to 
> do this, it gets a rich, functional 'person' object (meant for internal use 
> only) from the business services and copies the information into the DTO.
> 
> PersonDTO getPersonDetails (int personId) {
>     PersonObject p = BusinessServices.GetPerson(personId);
>     PersonDetails pd = new PersonDetails();
>     pd.firstName = p.firstName;
>     pd.lastName = p.lastName;
>     pd.AddressLine1 = p.AddressLine1;
>    ... etc etc
>     return pd;
> }
> 
> now, if PersonObject was a subclass of PersonDTO, I wouldn't have to copy 
> all the fields; I could just return p. However, there are some properties of 
> PersonObject I definitely don't want the caller to know about.

That doesn't tell me anything I hadn't already gleaned from your last 
message.  What I don't understand is why it is not sufficient that the 
method's return type is specified as PersonDTO.  Yes, a malicious 
programmer who obtained your library could hack into the details at 
runtime via reflection or a debugger, but is that an eventuality that 
you really need to worry about?  Is it more serious than the possibility 
that the same malicious programmer might extract any class he wants from 
your library jar and decompile it?  Or even insert a modified version? 
Is the program even going to run in an environment that exposes it to 
these risks?

You would gain some measure of protection by making PersonObject 
package-private (if you haven't already) but someone seriously out to 
crack your code _will_.  What are the consequences if someone does?  Is 
partial protection against those consequences worth the effort?

In general I wonder whether your application might benefit from some 
refactoring.  The concept of making PersonObject a subclass of PersonDTO 
simply to avoid copying fields seems rather strange to me (and the idea 
is the source of your present problem).  I can't comment further on 
that, however, because I haven't enough code to see the big picture.


John Bollinger
[EMAIL PROTECTED]



== 2 of 3 ==
Date:   Thurs,   Nov 11 2004 6:05 am
From: "Andy Fish" <[EMAIL PROTECTED]> 


"John C. Bollinger" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Andy Fish wrote:
>> OK, here's a sample. The API returns a PersonDTO (Data Transfer Object). 
>> to do this, it gets a rich, functional 'person' object (meant for 
>> internal use only) from the business services and copies the information 
>> into the DTO.
>>
>> PersonDTO getPersonDetails (int personId) {
>>     PersonObject p = BusinessServices.GetPerson(personId);
>>     PersonDetails pd = new PersonDetails();
>>     pd.firstName = p.firstName;
>>     pd.lastName = p.lastName;
>>     pd.AddressLine1 = p.AddressLine1;
>>    ... etc etc
>>     return pd;
>> }
>>
>> now, if PersonObject was a subclass of PersonDTO, I wouldn't have to copy 
>> all the fields; I could just return p. However, there are some properties 
>> of PersonObject I definitely don't want the caller to know about.
>
> That doesn't tell me anything I hadn't already gleaned from your last 
> message.  What I don't understand is why it is not sufficient that the 
> method's return type is specified as PersonDTO.  Yes, a malicious 
> programmer who obtained your library could hack into the details at 
> runtime via reflection or a debugger, but is that an eventuality that you 
> really need to worry about?  Is it more serious than the possibility that 
> the same malicious programmer might extract any class he wants from your 
> library jar and decompile it?  Or even insert a modified version? Is the 
> program even going to run in an environment that exposes it to these 
> risks?
>

Thanks John (and others) for the replies. What I was concerned about is, say 
the person object contains details about that person's privileges. If a 
hacker could change those privileges with a debugger they might be able to 
do things they aren't supposed to do.

However, I take your point about decompiling. If someone running in the same 
JVM wanted to get those privileges they ultimately could, because in the end 
my code is just a bunch of routines that access some underlying data store, 
and the JVM must have access to that data store.

so I guess cases where I realistically need to worry about being hacked are 
where someone is calling the API from outside the JVM (e.g. SOAP). In this 
case, as long as I ensure that only the public fields (i.e. those from 
PersonDTO) get transmitted across the wire, I am OK.

Unfortunately that brings up another problem - to maximise the ability of 
reusing the interface in different places, the DTO object should be 
serializable. However, the Person object will definitely not be serialisable 
so that might put the kibosh on the whole idea

> You would gain some measure of protection by making PersonObject 
> package-private (if you haven't already) but someone seriously out to 
> crack your code _will_.  What are the consequences if someone does?  Is 
> partial protection against those consequences worth the effort?
>
> In general I wonder whether your application might benefit from some 
> refactoring.  The concept of making PersonObject a subclass of PersonDTO 
> simply to avoid copying fields seems rather strange to me (and the idea is 
> the source of your present problem).  I can't comment further on that, 
> however, because I haven't enough code to see the big picture.
>
>
> John Bollinger
> [EMAIL PROTECTED] 





== 3 of 3 ==
Date:   Thurs,   Nov 11 2004 8:37 am
From: "Stefan Schulz" <[EMAIL PROTECTED]> 

On Thu, 11 Nov 2004 14:05:40 GMT, Andy Fish <[EMAIL PROTECTED]>  
wrote:

>
> Thanks John (and others) for the replies. What I was concerned about is,  
> say the person object contains details about that person's privileges. If 
> a hacker could change those privileges with a debugger they might be  
> able to do things they aren't supposed to do.

In that case you definitly need to re-think your security design. You  
should
always authorize any "privileged" operation in the operation context, not
in some user context. You should also keep authorization information  
directly
tied to some user (maybe by using a Certificate for that user)

Ultimately, however, if your cracker has your application in her debugger,
you've lost anyway. She can just remove the access check methods, or make
them accept anything.

> However, I take your point about decompiling. If someone running in the  
> same JVM wanted to get those privileges they ultimately could, becausein  
> the end my code is just a bunch of routines that access someunderlying  
> data store, and the JVM must have access to that data store.

Exactly.

> so I guess cases where I realistically need to worry about being hacked  
> are where someone is calling the API from outside the JVM (e.g. SOAP).  
> In this case, as long as I ensure that only the public fields (i.e. those 
> from PersonDTO) get transmitted across the wire, I am OK.

Exactly.

> Unfortunately that brings up another problem - to maximise the ability of
> reusing the interface in different places, the DTO object should be
> serializable. However, the Person object will definitely not be  
> serialisable so that might put the kibosh on the whole idea

This merely goes to show that the Person class should not inherit from
DataTransferObject, but instead have some createDTA() method that
constructs one.


-- 

Whom the gods wish to destroy they first call promising.




==========================================================================
TOPIC: CachedRowSet update problem
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cdde2e9b6a8fd68f
==========================================================================

== 1 of 1 ==
Date:   Thurs,   Nov 11 2004 6:58 am
From: "Seref Arikan" <[EMAIL PROTECTED]> 

Hi,
I am trying to update some data in db using cachedrowset, and somehow, i
could not manage to get it work. I am getting X number of conflicts
exception, X being whatever the number of rows cachedrowset instance
includes.
It seems to be a bug or maybe something about drivers ? any ideas ?

Info is as follows :
Windows xp, j2se 1.5 (call it 5 if you like :) oracle db version 8.1.7

code and exception are as follows
----------------------------------------------------------------------------
-----------------------
            Class.forName("oracle.jdbc.driver.OracleDriver");
            //      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

            CachedRowSet wrs = new CachedRowSetImpl();

            wrs.setCommand("select * from emp where ename='SMITH'");

            wrs.setUsername("scott");
            wrs.setPassword("tiger");
            wrs.setUrl("jdbc:oracle:thin:@localhost:1521:Oralocal");
              wrs.execute();
            wrs = wrs;
            wrs.setKeyColumns(new int[]{1});
            wrs.absolute(1);
            wrs.updateString(2,"Ahha update");
            wrs.updateRow();
            wrs.acceptChanges();
----------------------------------------------------------------------------
-----------------------
javax.sql.rowset.spi.SyncProviderException: 1 conflicts while synchronizing


any help is appreciated a lot
Best Regards






==========================================================================
TOPIC: Remove punctuation from String?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/397f172e95f24d78
==========================================================================

== 1 of 5 ==
Date:   Thurs,   Nov 11 2004 7:06 am
From: "dfhLASST" <[EMAIL PROTECTED]> 

What is the best way to remove all non-alphabetic characters (e.g. symbols,
spaces etc.) from a String?

My original plan was to loop round the chars in the String and add them to
an array if the value of the chars are alphabetic (i.e. >=65 and <=122).
I've ran into problems with this and it seems more complex than the problem
should be.

Any suggestions?





== 2 of 5 ==
Date:   Thurs,   Nov 11 2004 7:15 am
From: Michael Borgwardt <[EMAIL PROTECTED]> 

dfhLASST wrote:
> What is the best way to remove all non-alphabetic characters (e.g. symbols,
> spaces etc.) from a String?
> 
> My original plan was to loop round the chars in the String and add them to
> an array if the value of the chars are alphabetic (i.e. >=65 and <=122).
> I've ran into problems with this and it seems more complex than the problem
> should be.

The problem is more complex than you think. Are you absolutely sure than
you're only ever going to process English text? If not, use Character.isLetter()
for the condition.

For the accumulation of the output string, use StringBuffer (I gess that's
where you encountered obvious problems).



== 3 of 5 ==
Date:   Thurs,   Nov 11 2004 7:43 am
From: Chris Smith <[EMAIL PROTECTED]> 

dfhLASST wrote:
> What is the best way to remove all non-alphabetic characters (e.g. symbols,
> spaces etc.) from a String?
> 
> My original plan was to loop round the chars in the String and add them to
> an array if the value of the chars are alphabetic (i.e. >=65 and <=122).
> I've ran into problems with this and it seems more complex than the problem
> should be.
> 
> Any suggestions?

str = str.replaceAll("[^A-Za-z]", "");

or, if you want more than just ASCII characters:

str = str.replaceAll("[^\\p{L}]", "");

-- 
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation



== 4 of 5 ==
Date:   Thurs,   Nov 11 2004 7:50 am
From: "dfhLASST" <[EMAIL PROTECTED]> 

"Michael Borgwardt" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> dfhLASST wrote:
> > What is the best way to remove all non-alphabetic characters (e.g.
symbols,
> > spaces etc.) from a String?
> >
> > My original plan was to loop round the chars in the String and add them
to
> > an array if the value of the chars are alphabetic (i.e. >=65 and <=122).
> > I've ran into problems with this and it seems more complex than the
problem
> > should be.
>
> The problem is more complex than you think. Are you absolutely sure than
> you're only ever going to process English text? If not, use
Character.isLetter()
> for the condition.
>
> For the accumulation of the output string, use StringBuffer (I gess that's
> where you encountered obvious problems).

Thanks, yeah I used that.

For future reference for anyone else here is my method:


 public String stripPunctuation(String s) {

  StringBuffer sb = new StringBuffer();

  for (int i = 0; i < s.length(); i++) {
   if ((s.charAt(i) >= 65 && s.charAt(i) <= 90) || (s.charAt(i) >= 97 &&
s.charAt(i) <= 122)) {

    sb = sb.append(s.charAt(i));
   }
  }

  return sb.toString();
 }





== 5 of 5 ==
Date:   Thurs,   Nov 11 2004 7:57 am
From: "Woebegone" <[EMAIL PROTECTED]> 

"Michael Borgwardt" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> dfhLASST wrote:
>> What is the best way to remove all non-alphabetic characters (e.g. 
>> symbols,
>> spaces etc.) from a String?

8<
>
> The problem is more complex than you think. Are you absolutely sure than
> you're only ever going to process English text? If not, use 
> Character.isLetter()
> for the condition.
>
> For the accumulation of the output string, use StringBuffer (I gess that's
> where you encountered obvious problems).

I've used something like the following in cases where I know the processing 
is constrained to a given (relatively small) set of characters, e.g. English 
text. It has the advantage of allowing easy extension by adding characters 
to ALPHABET without necessarily requiring char codes.

/* */
public class StringCleanser {
  public static final String ALPHABET =
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
    "abcdefghijklmnopqrstuvwxyz";
  public static boolean isAlphabetic(char c) {
    return StringCleanser.ALPHABET.indexOf(c) != -1;
  }
  public static String cleanse(String s) {
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < s.length(); i++) {
      if (StringCleanser.isAlphabetic(s.charAt(i))) {
        buf.append(s.charAt(i));
      }
    }
    return buf.toString();
  }
  public static void main(String[] args) {
    String in = "L e,f.t/o;v'e[r]L1e.2t3t4e ,5r6s7";
    System.out.println(StringCleanser.cleanse(in));
  }
}
/* */
-- 
Regards,
Sean. 






==========================================================================
TOPIC: RegEx partial matching
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/14069fafc93c4493
==========================================================================

== 1 of 4 ==
Date:   Thurs,   Nov 11 2004 7:33 am
From: Stanimir Stamenkov <[EMAIL PROTECTED]> 

Is it possible to detect a partial match at the end of the supplied 
data?, i.e.:

     String data = "A regular expression, specified as a string, 
must first be compiled into an instance of this class. The resulting 
pattern can then be used";

     String search = "can then be used to create";

     Pattern pattern = Pattern.compile(search);

     Matcher matcher = pattern.matcher(data);

     matcher.find();
     ...

It is obvious the above won't match but then the initial data is 
only a chunk from an input stream (for example), so I want to detect 
if the pattern has been partially matched and at which position the 
partial match begins so I could prepend it to the next data chunk 
and continue matching.

-- 
Stanimir



== 2 of 4 ==
Date:   Thurs,   Nov 11 2004 10:22 am
From: "Chris" <anon> 

"Stanimir Stamenkov" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Is it possible to detect a partial match at the end of the supplied
> data?, i.e.:
>
>      String data = "A regular expression, specified as a string,
> must first be compiled into an instance of this class. The resulting
> pattern can then be used";
>
>      String search = "can then be used to create";
>
>      Pattern pattern = Pattern.compile(search);
>
>      Matcher matcher = pattern.matcher(data);
>
>      matcher.find();
>      ...
>
> It is obvious the above won't match but then the initial data is
> only a chunk from an input stream (for example), so I want to detect
> if the pattern has been partially matched and at which position the
> partial match begins so I could prepend it to the next data chunk
> and continue matching.

You can't know that it's a true match until you get the next chunk. So you'd
have to set a "might be a match" flag, fetch the next chunk, concatenate it,
and then try to match again. Or check to see if the first part of the next
chunk matched the last part of the regex.

This logic is tricky enough that I wouldn't bother trying. Instead, access
your chunks though a custom object that implements the CharSequence
interface. Feed that to your matcher. That way you can fetch the next chunk
when you run out of chars in the first chunk, and it's all transparent to
your matcher. This is a much cleaner design.





== 3 of 4 ==
Date:   Thurs,   Nov 11 2004 10:42 am
From: Stanimir Stamenkov <[EMAIL PROTECTED]> 

/Chris/:
> "Stanimir Stamenkov" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> 
>> It is obvious the above won't match but then the initial data is
>> only a chunk from an input stream (for example), so I want to detect
>> if the pattern has been partially matched and at which position the
>> partial match begins so I could prepend it to the next data chunk
>> and continue matching.
> 
> You can't know that it's a true match until you get the next chunk. So you'd
> have to set a "might be a match" flag, fetch the next chunk, concatenate it,
> and then try to match again. Or check to see if the first part of the next
> chunk matched the last part of the regex.

That's exactly what I'm saying I need to do and what I need the 
partial "might be a" match detection for.

> This logic is tricky enough that I wouldn't bother trying. Instead, access 
> your chunks though a custom object that implements the CharSequence 
> interface. Feed that to your matcher. That way you can fetch the next chunk 
> when you run out of chars in the first chunk, and it's all transparent to 
> your matcher. This is a much cleaner design.

If you read the other reply from "bilbo" (Adam) you would notice I 
couldn't implement CharSequence interface over a stream.

-- 
Stanimir



== 4 of 4 ==
Date:   Thurs,   Nov 11 2004 10:44 am
From: Stanimir Stamenkov <[EMAIL PROTECTED]> 

/bilbo/:

> The Jakarta-Regexp library uses a CharacterIterator interface instead 
> of a CharSequence.  CharacterIterator can be implemented over streams, 
> so you can do what you're trying to do, as in
> 
> import org.apache.regexp.*;
> ...
> java.io.Reader myReader = ...;
> RE regex = new RE("Your long string");
> regex.match(new ReaderCharacterIterator(myReader));
> 
> You can get the Jakarta-Regexp library here:
> http://jakarta.apache.org/regexp/

Thank you, Adam - this is exactly what I need.

-- 
Stanimir




==========================================================================
TOPIC: test javamail file
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/49e12ffa7e150d55
==========================================================================

== 1 of 1 ==
Date:   Thurs,   Nov 11 2004 7:43 am
From: "Andy Fish" <[EMAIL PROTECTED]> 

sounds like you don't have the classpath set correctly when running the 
program (you need to include the same javamail jars as when compiling)

"yihan" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hello,
> I added mail.jar and activation.jar into CLASSPATH, and compile 
> msgsend.java successfully. But
> when I input
> [prompt] java msgsend -o [EMAIL PROTECTED] -M SMTP.Server [EMAIL PROTECTED]
> under dos. SMTP.Server is replaced by 130.232.80.15 (My mail server IP). 
> It comes error:
> Execption in thread "main" java.lang.NoClassDefFoundError: 
> javax/mail/Message
>
> Can anybody tell me how to solve it? Thank you.
>
> Zhao
> 






==========================================================================
TOPIC: Authenticator Question
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7eaecb4ca1f08577
==========================================================================

== 1 of 1 ==
Date:   Thurs,   Nov 11 2004 7:46 am
From: "No Comment" <[EMAIL PROTECTED]> 

I am attempting to retrieve a file from a URL secured by IDC Security.  I am
using the following to attempt to code for this:

import java.net.Authenticator;

import java.net.PasswordAuthentication;

public class MyAuthenticator extends Authenticator {

protected PasswordAuthentication getPasswordAuthentication() {

String userName = "username";

String password = "password";


return new PasswordAuthentication(userName, password.toCharArray());

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

URL url = new URL(sourceName);

HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();

Authenticator.setDefault(new MyAuthenticator());

((HttpURLConnection) urlConnection).setInstanceFollowRedirects(false);

InputStream inputStream = url.openStream();

// Now we can create our output stream, the new file name is applied here:

FileOutputStream fileOutputStream = new FileOutputStream(destinationName);

....



I am getting the message 'Server redirected to many times (5)' and a return
status code of 401, Unauthorized.  Yet I am able to retrieve the file via my
browser with the same login credentials.

Can anyone tell me what I might be doing wrong?


Thanks,

Mark








==========================================================================
TOPIC: EnableSerializationFocusListener usage?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8e36f3f834dd317
==========================================================================

== 1 of 1 ==
Date:   Thurs,   Nov 11 2004 8:21 am
From: "Jim Crowell" <[EMAIL PROTECTED]> 

I have rewritten my Focus Management scheme using the Focus System of Java 
1.4.2.

My app is Form Centric and contains a custom class for each field of a form. 
I manage the Focus Gained / Focus Lost processing of each field class to 
satisfy some pre / post processing requirements.

During the debug phase I noticed that each 'field' class has the following 
Focus Listener:

EnableSerializationFocusListener


To the best of my knowledge I am no using the Serialization interface 
anywhere in my code.

I am unable to find anything on the Net that describes this Listener and how 
it is used.

Any ideas as to what it is and is it necessary?

Regards,
Jim...






==========================================================================
TOPIC: How to handle attachments with axis
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1052ce4ea95bafd7
==========================================================================

== 1 of 2 ==
Date:   Thurs,   Nov 11 2004 8:22 am
From: "Stephan Koser" <[EMAIL PROTECTED]> 

Hi,

can anybody tell me how to handle attachments with Axis? I don't want to
send Attachments as a method parameter but as real Attachment (using
addAttachmentPart()).
Using this function on the client side works well, but what ist to do on the
server side to read the attachments?
Usually I have a operation with parameters to call, that is a particular
method on the server side. So, when the Call is sent, the method on the
server is called, e.g.

public String fileApplication(String applicationName, Date date)

The application content was attached on the client as Attachment. How can I
access the attachments in the method fileApplication()?

The only way I know is to write a Servlet that catches the whole SOAPMessage
like the following:


public class SimpleJAXMServlet
  extends javax.xml.messaging.JAXMServlet
  implements javax.xml.messaging.ReqRespListener {


 public void init(javax.servlet.ServletConfig servletConfig)
   throws javax.servlet.ServletException {
  super.init(servletConfig);
 }

 public javax.xml.soap.SOAPMessage onMessage
   (javax.xml.soap.SOAPMessage message) {
  ...
  Iterator attachments = message.getAttachments();
  ...

 }
...
}

But this is the solution without Axis. Is there a way to use Axis to
retrieve the Attachments in a more comfortable way?

Thank you!

-- 
bye Stephan...





== 2 of 2 ==
Date:   Thurs,   Nov 11 2004 10:22 am
From: "Andy Flowers" <[EMAIL PROTECTED]> 

Take a look at the MessageContext class and use it like

    MessageContext mc = MessageContext.getCurrentContext();

    mc.getCurrentMessage().countAttachments();

"Stephan Koser" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi,
>
> can anybody tell me how to handle attachments with Axis? I don't want to
> send Attachments as a method parameter but as real Attachment (using
> addAttachmentPart()).
> Using this function on the client side works well, but what ist to do on 
> the
> server side to read the attachments?
> Usually I have a operation with parameters to call, that is a particular
> method on the server side. So, when the Call is sent, the method on the
> server is called, e.g.
>
> public String fileApplication(String applicationName, Date date)
>
> The application content was attached on the client as Attachment. How can 
> I
> access the attachments in the method fileApplication()?
>
> The only way I know is to write a Servlet that catches the whole 
> SOAPMessage
> like the following:
>
>
> public class SimpleJAXMServlet
>  extends javax.xml.messaging.JAXMServlet
>  implements javax.xml.messaging.ReqRespListener {
>
>
> public void init(javax.servlet.ServletConfig servletConfig)
>   throws javax.servlet.ServletException {
>  super.init(servletConfig);
> }
>
> public javax.xml.soap.SOAPMessage onMessage
>   (javax.xml.soap.SOAPMessage message) {
>  ...
>  Iterator attachments = message.getAttachments();
>  ...
>
> }
> ...
> }
>
> But this is the solution without Axis. Is there a way to use Axis to
> retrieve the Attachments in a more comfortable way?
>
> Thank you!
>
> -- 
> bye Stephan...
>
> 






==========================================================================
TOPIC: Multi-threaded access to a file on disk
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fc88e19bbf867357
==========================================================================

== 1 of 1 ==
Date:   Thurs,   Nov 11 2004 9:14 am
From: "Steve W. Jackson" <[EMAIL PROTECTED]> 

In article <[EMAIL PROTECTED]>, "Chris" <anon> wrote:

>:"Steve W. Jackson" <[EMAIL PROTECTED]> wrote in message
>:news:[EMAIL PROTECTED]
>:> In article <[EMAIL PROTECTED]>, "Chris" <anon> wrote:
>:>
>:> >:We have a web app that needs to access a very large file on disk. This
>:app
>:> >:will have a large number of simultaneous users. The file is too big to
>:fit
>:> >:entirely in memory.
>:> >:
>:> >:I'd really like for different threads to be able to read different parts
>:of
>:> >:the file without synchronizing access. Unfortunately, RandomAccessFile
>:isn't
>:> >:multithreaded, because you have to call seek() and then read().
>:> >:
>:> >:At the moment we can't use NIO and ByteBuffers because we have to
>:support
>:> >:JDK 1.3.
>:> >:
>:> >:Does anyone know how to solve this problem?
>:>
>:> You don't mention writing, only reading.  Are you actually getting
>:> failures in your current attempts to read from multiple threads?  I
>:> can't see any reason why it should be hampered unless Java or the
>:> underlying filesystem are somehow preventing it.
>:
>:The difficulty is the you need to make two calls to RandomAccessFile to read
>:anything: seek(), and then read(). If you don't synchronize, then one thread
>:could seek, the next thread could seek, then thread 1 could read, and then
>:thread 2 could read. Each thread would get the wrong data.

I should've been more clear.  My question was whether Java or the 
underlying filesystem would allow each of your threads to have their own 
RandomAccessFile objects referring to the same physical file (assuming 
this is read-only access) without difficulties.

= Steve =
-- 
Steve W. Jackson
Montgomery, Alabama




==========================================================================
TOPIC: cannot resolve symbol errors
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/321eb384d3f247e0
==========================================================================

== 1 of 2 ==
Date:   Thurs,   Nov 11 2004 9:23 am
From: "Jody" <[EMAIL PROTECTED]> 

Hey, i'm having issues with the following code:
package dbase;

import java.util.Vector;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;


public class Register extends DataBase
{
public Register()
{

}

public Vector getBookLoansColumnHeadings()
{
Vector headings = new Vector();
this.setConnection();
try
{
Statement st = conn.createStatement();
String sql = "Select * from library where BorrowerID < 1";

// get the meta data from the ResultSet
ResultSet rs = st.executeQuery(sql);

ResultSetMetaData rsmd = rs.getMetaData();
for (int x= 1 ; x <= rsmd.getColumnCount(); x++)
{
headings.addElement(rsmd.getColumnName(x));
}
rs.close();
st.close();
this.closeConnection();
}
catch (Exception ex)
{
System.out.println(ex.getMessage());
}
return headings;
}
public Vector getBookLoansData()
{
Vector BookLoansData = new Vector();
this.setConnection();
try
{
Statement st = conn.createStatement();
String sql = "Select * from library"; // get all the records
ResultSet rs = st.executeQuery(sql);
ResultSetMetaData rsmd = rs.getMetaData();
while (rs.next()) // loop through all the records
{
Vector myrow = new Vector(); // create a vector for each row
// Note: indexed from 1 to N not 0 to N-1
for (int x= 1 ; x <= rsmd.getColumnCount(); x++)
{
myrow.addElement(rs.getString(x));
}
// add vector to overall vector
BookLoansData.addElement(myrow);
}
rs.close();
st.close();
this.closeConnection();
}
catch(Exception ex)
{
System.out.println(ex.getMessage());
}
return BookLoansData;
}
}

The errors i get are as follows:

cannot resolve symbol
symbol : class DataBase
location: class dbase.Register
public class Register extends DataBase
^
cannot resolve symbol
symbol : method setConnection ()
location: class dbase.Register
this.setConnection();
^
cannot resolve symbol
symbol : variable conn
location: class dbase.Register
Statement st = conn.createStatement();
^
cannot resolve symbol
symbol : method closeConnection ()
location: class dbase.Register
this.closeConnection();
^
cannot resolve symbol
symbol : method setConnection ()
location: class dbase.Register
this.setConnection();
^
cannot resolve symbol
symbol : variable conn
location: class dbase.Register
Statement st = conn.createStatement();
^
cannot resolve symbol
symbol : method closeConnection ()
location: class dbase.Register
this.closeConnection();
^
Has this got something to do with packages, or is it something really 
obvious? 





== 2 of 2 ==
Date:   Thurs,   Nov 11 2004 9:46 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On Thu, 11 Nov 2004 17:23:49 -0000, Jody wrote:

> Hey, i'm having issues with the following code:

> package dbase;

> Has this got something to do with packages, or is it something really 
> obvious?

Everything to do with packages.

I take it you have the DataBase.java source in the 
same directory (package) as Register.java?

> import java.util.Vector;
> import java.sql.Statement;
> import java.sql.ResultSet;
> import java.sql.ResultSetMetaData;
> 
> public class Register extends DataBase
> {

(big snip..)
> cannot resolve symbol
> symbol : class DataBase

First stop for the basic errors
<http://mindprod.com/jgloss/compileerrormessages.html>
<http://mindprod.com/jgloss/runerrormessages.html>

Or, in this specific case, 
<http://mindprod.com/jgloss/compileerrormessages.html#CANNOTRESOLVESYMBOL>
point four.

You do not import 'DataBase', are they in the same package?

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane




==========================================================================
TOPIC: Struts iterate indexed nested objects
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4308a477a108f808
==========================================================================

== 1 of 1 ==
Date:   Thurs,   Nov 11 2004 10:10 am
From: Sudsy <[EMAIL PROTECTED]> 

Stratocaster wrote:
<snip>
> The only conclusion I can come up with is that this is a bug in struts
> or it wasn't designed to work with object hierarchies more than one
> deep (which I doubt).

You're right: it wasn't designed for that. There are code mechanisms
one can use to get around the limitations.

> I can not see how, with the HTML generated in your example, it can
> work.  Struts has no idea where to stuff "checkItems" when the form is
> submitted.
> 
> I guess it boils down to the HTML that is generated in this example. 
> There is no way Struts can figure out the object hierarchy.

The code is all there and DOES work. What's happening is just a bit
tricky. What you should really be doing is testing, and examining
the data sent when the form is sumbitted. Here's an extract from my
Apache logs:

GET /Echo.do? \
stringField%5B0%5D.value=testing+0& \
stringField%5B0%5D.status=accept&\
checkItem%5B1%5D.checked=0& \
stringField%5B1%5D.value=testing+1& \
stringField%5B1%5D.status=reject& \
checkItem%5B1%5D.checked=1 \
HTTP/1.1

I've split the lines for easier reading. Note that checkItem[1] is
present twice with different values. The value is actually the index.
Now go back to my article and see how multiple values are handled,
in particular FormCheckItem#setChecked( String[] ).
Then try to follow the logic as I make the connection back to the
ComplexObject. I realize that it's scary stuff, but I can assure
you that it works. If you cut-and-paste the code and perform your
own experimentation then I'm sure you'll discover how to achieve
your stated goal.
Of course, if you want to pay me to do it...

-- 
Java/J2EE/JSP/Struts/Tiles/C/UNIX consulting and remote development.





==========================================================================
TOPIC: Http to port different than 80?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/83c9369f58ffcd00
==========================================================================

== 1 of 1 ==
Date:   Thurs,   Nov 11 2004 10:29 am
From: "Andy Flowers" <[EMAIL PROTECTED]> 

http://jakarta.apache.org/commons/httpclient/ is the place to find the 
Jakarta HttpClient and a wealth of samples.

For example, using a GET method would look something like (ripped off from 
the site shown above)
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import java.io.*;

public class HttpClientTutorial {
  private  String String url = "http://myTestServer:8190/query?"; + 
URLEncoder.encode("<myXMLQuery>", "UTF-8");
  public static void main(String[] args) {
    // Create an instance of HttpClient.
    HttpClient client = new HttpClient();

    // Create a method instance.
    GetMethod method = new GetMethod(url);

    // Provide custom retry handler is necessary
    DefaultMethodRetryHandler retryhandler = new 
DefaultMethodRetryHandler();
    retryhandler.setRequestSentRetryEnabled(false);
    retryhandler.setRetryCount(3);
    method.setMethodRetryHandler(retryhandler);

    try {
      // Execute the method.
      int statusCode = client.executeMethod(method);

      if (statusCode != HttpStatus.SC_OK) {
        System.err.println("Method failed: " + method.getStatusLine());
      }

      // Read the response body.
      byte[] responseBody = method.getResponseBody();

      // Deal with the response.
      // Use caution: ensure correct character encoding and is not binary 
data
      System.out.println(new String(responseBody));

    } catch (IOException e) {
      System.err.println("Failed to download file.");
      e.printStackTrace();
    } finally {
      // Release the connection.
      method.releaseConnection();
    }
  }
}
> 






==========================================================================
TOPIC: currentThread, getContextClassLoader and get resource
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e4c0429549cea577
==========================================================================

== 1 of 1 ==
Date:   Thurs,   Nov 11 2004 10:50 am
From: "PerfectDayToChaseTornados" <[EMAIL PROTECTED]> 

"Gleb" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
| I've got a strange situation.
| I have third-party jar file which classes I am using in my app. The
| used class has
| URL url =
Thread.currentThread().getContextClassLoader().getResource("config.xml");
| in one of its method.
|
| When I run my app application compilied in class-files everything is
| allright, but when I put it in jar-file url becomes null. Jar-file
| contains my classes and all third-party classes plus config.xml in the
| root of jar-file. The most strange thing is that when I run
| URL url =
Thread.currentThread().getContextClassLoader().getResource("config.xml");
|  from the mthod of my class config.xml is available. So basically
| config.xml is richable from my class but not from hird-party class
| withing one jar-file. I've tried to put config.xml into different
| directories withing jar-file without success.
| Could be any particular detailes about this third-party class
| implementation? Or any reason why ContextClassLoader behaves
| differently in my class and third-party class? I really don't have any
| ideas any more :(.

This excellent paper on classloaders will help you understand what is going
on here
http://www.javageeks.com/Papers/ClassForName/ClassForName.pdf

-- 
-P
"Programs that are hard to read are hard to modify.
  Programs that have duplicated logic are hard to modify.
  Programs with complex conditional logic are hard to modify"

( Kent Beck)






==========================================================================
TOPIC: Need as much help as possible
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7c8e64b34d7154d8
==========================================================================

== 1 of 2 ==
Date:   Thurs,   Nov 11 2004 11:04 am
From: "WCU_Student3456" <[EMAIL PROTECTED]> 

hey i'm new to the java scene and i have a major assignment due for class
on the 12th of nov.  I need help with a program that has a point class...a
driver and a circle class. the program is suppost to display info about the
circle...if anyone is interested or has pitty...college students love
pitty..please respond and i will try to send the assignment to you...i
have it scanned on adobe...

thanks ever so much




== 2 of 2 ==
Date:   Thurs,   Nov 11 2004 11:11 am
From: [EMAIL PROTECTED] (Kristofer Pettijohn) 

WCU_Student3456 <[EMAIL PROTECTED]> wrote:
> hey i'm new to the java scene and i have a major assignment due for class
> on the 12th of nov.  I need help with a program that has a point class...a
> driver and a circle class. the program is suppost to display info about the

"supposed", not "suppost".

> circle...if anyone is interested or has pitty...college students love
> pitty..please respond and i will try to send the assignment to you...i
> have it scanned on adobe...
> thanks ever so much

We don't do homework in here.  If you have questions, or are unclear
about something, or want us to check your code and help you troubleshoot
a problem, we can do that.

Kristofer



=======================================================================

You received this message because you are subscribed to the
Google Groups "comp.lang.java.programmer".  

comp.lang.java.programmer
[EMAIL PROTECTED]

Change your subscription type & other preferences:
* click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe

Report abuse:
* send email explaining the problem to [EMAIL PROTECTED]

Unsubscribe:
* click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe


=======================================================================
Google Groups: http://groups-beta.google.com 

Reply via email to