"Lerenc, Vedran" wrote:

> Hi Steve,
>
> please try to implement the follwing method to avoid caching:
>
>     /**
>      * Interface method needed to be implemented in order to control caching
> behaviour.
>      * When returning true, the served resource is cachable, otherwise it's
> not cachable
>      * and the init method will always be called for each request.
>      * @return flag indicating whether or not the served resource is
> cachable
>      */
>     public boolean isCacheable ( )
>     {
>         return false;
>     }
>
> Cheers,
>
> Vedran
>
> > -----Original Message-----
> > From: sbelt [mailto:[EMAIL PROTECTED]]
> > Sent: Mittwoch, 8. November 2000 09:12
> > To: JetSpeed
> > Subject: Cannot get around cache
> >
> >
> > I am trying to create a portlet which does not use the
> > Jetspeed cache when
> > fetching content from a URL. For some reason, I cannot skip
> > the Jetspeed
> > caching system. I see this by looking at the jetspeed log:
> >
> > [Wed Nov 08 08:53:11 PST 2000] -- NOTICE  --
> > JetspeedDiskCache::getEntry(...) cache hit:
> > http://development.mysite.com/todolist/PortletScheduleDisplay.asp
> >
> > Also confusing to me is that if I go into the cache folder
> > and delete the
> > cached file, the log still shows a cache hit and the portlet displays
> > properly on the webpage.
> >
> > I guess I am not clear when my portlet class is called by Jetspeed.
> > Apparently, if the file is in cache, there is no need to
> > access my portlet
> > code (which makes logical sense). So how do I either tell
> > jetspeed not to
> > put the file into cache when it is first retrieved, or, tell
> > jetspeed not to
> > check the cache when the portlet is called.
> >
> > (BTW - I am trying to improve my Jetspeed coding skills, so
> > if someone will
> > tell me which classes are used by this process, I will try to
> > make the code
> > modifications myself)
> >
> > Thankyou in advance for any assistance!
> >
> > Steve B.
> >
> > PS - Here is the portlet code I am using
> >
> > <bunch of imports snip...>
> >
> > public class LoginURL extends FileServerPortlet {
> >     public void init() throws PortletException {
> >
> >         PortletConfig config = this.getPortletConfig();

Note: Rundata below should be taken ONLY from the (new) getContent(RunData data)
call. It has dissapeared from config currently due to heavy multithreading
issues with this implementation.

So, you are not allowed to use RunData in the init() method. The user and
password only makes sense in the context of a given request.

All initialization now is independent of RunData information.
PortletConfig is safe, but it will have only parameters from the registry
markup. Parameters from the user markup will be handled via the Session or the
Request parameters. (The PortletConfig stuff is not finished.)

>
> >         RunData rundata = config.getRunData();
> >      String userid = rundata.getUser().getUserName();
> >      String password = rundata.getUser().getPassword();
> >
> >         //fetch the URL as a String...
> >
> >         try {
> >   Log.note("accessing non-cached URL site "+config.getURL());
> >   Log.note("userid = "+userid);
> >   Log.note("password = "+password);
> >   String szPostString = "userid="+userid+"&password="+password;
> >             this.setContent( new
> > earElement( this.getURL( config.getURL(),szPostString ) ) );
> >
> >         } catch (Exception e) {
> >             throw new PortletException( e.getMessage() );
> >         }
> >
> >
> >     }
> >
> >     private String getURL(String url, String szMessage)
> > throws IOException {
> >
> >   int CAPACITY = 1024;
> >         ByteArrayOutputStream buffer = new ByteArrayOutputStream();
> >
> >   // open connection to the url
> >   URL srcUrl = new URL(url);
> >   URLConnection connection = srcUrl.openConnection();
> >
> >   // send the string
> >   connection.setDoOutput(true);
> >   PrintWriter out = new PrintWriter( connection.getOutputStream());

Use getWriter to get a character stream from the URL and avoid issues with
content-encoding. Else, it will break when your server encoding is different
from the URL encoding.

>
> >   out.println(szMessage);
> >   out.close();
> >
> >   // Display the results
> >   //now process the InputStream...
> >   InputStream is = connection.getInputStream();

Agais, use getReader to read characters and avoid problems with character
encoding

>
> >   byte[] bytes = new byte[CAPACITY];

char[] if you use getReader

>
> >
> >   int readCount = 0;
> >   while( ( readCount = is.read( bytes )) > 0 )
> >   {
> >    buffer.write( bytes, 0, readCount);
> >   }
> >
> >   is.close();
> >
> >   return buffer.toString();
> >     }
> > }
> >
> >
> >
> > --
> > --------------------------------------------------------------
> > Please read the FAQ! <http://java.apache.org/faq/>
> > To subscribe:        [EMAIL PROTECTED]
> > To unsubscribe:      [EMAIL PROTECTED]
> > Archives and Other:  <http://java.apache.org/main/mail.html>
> > Problems?:           [EMAIL PROTECTED]
> >
>
> --
> --------------------------------------------------------------
> Please read the FAQ! <http://java.apache.org/faq/>
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> Archives and Other:  <http://java.apache.org/main/mail.html>
> Problems?:           [EMAIL PROTECTED]



--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to