Hi Jerome,

Thanks very much for replying my post ... i got over my problem by checking
the referrer to the FileUpload resource as follows:

@Override //==> at FileUploader resource
    public void acceptRepresentation(Representation entity)
            throws ResourceException {
        try {
            //==> Get uploaded File & Save it
            UploadFile(entity);

            //==> Check if Referrer to this resource was the main page (html
interface restlet) then redirect to it 
            //    again so we can avoid the refresh page resubmission issue
and update 
            //    display if upload performed successfully

            if (getRequest().getReferrerRef() != null) {
               
getResponse().redirectPermanent("/myrestlet/main_interface");
            }else { 
                 //==>> i.e. no referrer from html main page though upload
was done directly by posting the file on this resource (using curl for
example). Reply file uploader with a message
                getResponse().setEntity("file successfully received",
MediaType.TEXT_PLAIN);
            }
        }

Thanks again Jerome,
Best Regards



jlouvel wrote:
> 
> Hi Mohamed,
> 
> You could use an HTML redirection in your result page instead of s HTTP
> redirect.
> 
> <meta http-equiv="Refresh" content="5;
> url=http://www.mycompany.com/target";> 
> 
> Best regards,
> Jerome Louvel
> --
> Restlet ~ Founder and Lead developer ~ http://www.restlet.org
> Noelios Technologies ~ Co-founder ~ http://www.noelios.com
> 
> 
> -----Message d'origine-----
> De : Mohamed Abdel-Aziz Bayoumi [mailto:[email protected]] 
> Envoye : lundi 22 decembre 2008 15:52
> A : [email protected]
> Objet : Response message before redirection
> 
> Hello Dear Developers,
> 
> I'm developing a simple Restlets application that allows users to upload
> files, which i process then provide them with links to download the output
> processed files... I'm using a main Restlet that is an HTTP representation
> including a form for upload and a summary table with recently uploaded
> files
> and a link to download each ... 
> When a file is uploaded using the HTML page's upload form, i specify the
> action to a FileUploader resource (Restlet) from which i redirect again
> permanently to the main restlet to avoid form's resubmission on refreshing
> the main page ... 
> 
> Now all that i wanna do is provide my users with upload status
> notification
> (a message ..  for example using getResponse().setEntity(" File
> successfully
> uploaded",MediaType.TEXT_PLAIN);) before redirecting them to the main page
> (this is for users who consume my restlet from  code without using HTTP's
> representation or GUI).... Problem is >> if i did both (i.e. provide
> message
> before/then redirect to main page) the former is completely neglected and
> all that they receive as a response from me is the HTTP representation
> printed on their consoles <http><head>...etc due to redirection to the
> main
> page .....
>    Is there any way they can receive the notification message while
> keeping
> the HTTP main page redirection for those who use the latter ??  
> 
> Best Regards  
> -- 
> View this message in context:
> http://n2.nabble.com/Response-message-before-redirection-tp1690275p1690275.html
> Sent from the Restlet Discuss mailing list archive at Nabble.com.
> 
> ------------------------------------------------------
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=989810
> 
> ------------------------------------------------------
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=991703
> 
> 

-- 
View this message in context: 
http://n2.nabble.com/Response-message-before-redirection-tp1690275p1802325.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=992168

Reply via email to