Re: Usage of Servlets in Wicket, How ?
I want to upload files through Commons FIleUpload API. As Commons FileUpload API requires HttpServletRequest for uploading files (e.g. fileItemsList = servletFileUpload.parseRequest(httpServletRequest)). Parsing HttpServletRequest is the necessary step while uploading in Commons FileUpload. I have got httpServletRequest from RequestCycle. e.g. ((ServletWebRequest) getRequest()).getHttpServletRequest() or ((WebRequest)requestCycle.getRequest()).getHttpServletRequest() but this request already being parsed automatically in RequestCycle, before reaching servletFileUpload.parseRequest(httpServletRequest). So, Request is already been parsed... exception occur. That's why i want to use Servlet's doGet(request, response) method for getting HttpServletRequest(without parsing). If not servlets, Is there any other way to handle FileUploading (through Apache Commons API) in wicket ? Thanks... From: Peter Thomas ptrtho...@gmail.com To: users@wicket.apache.org Sent: Tuesday, September 8, 2009 11:39:58 AM Subject: Re: Usage of Servlets in Wicket, How ? Refer this: http://cwiki.apache.org/WICKET/how-to-redirect-to-an-external-non-wicket-page.html If that doesn't help you should briefly explain what your requirement is. There may be a better way to achieve it within Wicket instead of hacking around with servlets. On Tue, Sep 8, 2009 at 10:57 AM, FaRHaN farhan.ba...@ymail.com wrote: but how can we call it from our wicket web page ? From: Jeremy Thomerson jer...@wickettraining.com To: users@wicket.apache.org Sent: Tuesday, September 8, 2009 11:10:49 AM Subject: Re: Usage of Servlets in Wicket, How ? servlets are totally separate from Wicket - write a servlet and add it to your web.xml. See any servlet example on the web (non-Wicket related) for assistance. -- Jeremy Thomerson http://www.wickettraining.com On Mon, Sep 7, 2009 at 11:54 PM, FaRHaN farhan.ba...@ymail.com wrote: Hi, Is there any example in Wicket that uses Servlets (doGet() doPost()). I mean how can we configure Servlets in our wicket application and use doGet(request, response) doPost(request, response) methods. I know web.xml configuration for Servlets but how can we use doGet() doPost() methods. Do we need wicket:ids in Servlets ? Is there any reference for such type of example ? Thanks...
Re: Usage of Servlets in Wicket, How ?
Maybe if you mention the specific reason(s) that you want to use Apache Commons FileUpload API rather than Wicket's built-in forms and file upload mechanisms, someone on the list will be able to provide you with more help. It seems that the FileUpload API is intended to help you if you have to write servlets to handle forms. But with Wicket, you don't have to do this. And if you use ACFU API, then you lose the rest of Wicket's stateful form handling. -- Jeremy Thomerson http://www.wickettraining.com On Tue, Sep 8, 2009 at 1:04 AM, FaRHaN farhan.ba...@ymail.com wrote: I want to upload files through Commons FIleUpload API. As Commons FileUpload API requires HttpServletRequest for uploading files (e.g. fileItemsList = servletFileUpload.parseRequest(httpServletRequest)). Parsing HttpServletRequest is the necessary step while uploading in Commons FileUpload. I have got httpServletRequest from RequestCycle. e.g. ((ServletWebRequest) getRequest()).getHttpServletRequest() or ((WebRequest)requestCycle.getRequest()).getHttpServletRequest() but this request already being parsed automatically in RequestCycle, before reaching servletFileUpload.parseRequest(httpServletRequest). So, Request is already been parsed... exception occur. That's why i want to use Servlet's doGet(request, response) method for getting HttpServletRequest(without parsing). If not servlets, Is there any other way to handle FileUploading (through Apache Commons API) in wicket ? Thanks... From: Peter Thomas ptrtho...@gmail.com To: users@wicket.apache.org Sent: Tuesday, September 8, 2009 11:39:58 AM Subject: Re: Usage of Servlets in Wicket, How ? Refer this: http://cwiki.apache.org/WICKET/how-to-redirect-to-an-external-non-wicket-page.html If that doesn't help you should briefly explain what your requirement is. There may be a better way to achieve it within Wicket instead of hacking around with servlets. On Tue, Sep 8, 2009 at 10:57 AM, FaRHaN farhan.ba...@ymail.com wrote: but how can we call it from our wicket web page ? From: Jeremy Thomerson jer...@wickettraining.com To: users@wicket.apache.org Sent: Tuesday, September 8, 2009 11:10:49 AM Subject: Re: Usage of Servlets in Wicket, How ? servlets are totally separate from Wicket - write a servlet and add it to your web.xml. See any servlet example on the web (non-Wicket related) for assistance. -- Jeremy Thomerson http://www.wickettraining.com On Mon, Sep 7, 2009 at 11:54 PM, FaRHaN farhan.ba...@ymail.com wrote: Hi, Is there any example in Wicket that uses Servlets (doGet() doPost()). I mean how can we configure Servlets in our wicket application and use doGet(request, response) doPost(request, response) methods. I know web.xml configuration for Servlets but how can we use doGet() doPost() methods. Do we need wicket:ids in Servlets ? Is there any reference for such type of example ? Thanks...
Re: Usage of Servlets in Wicket, How ?
I want to make it a separate API for file uploading. So that i can embed it in any of the application regardless of the framework (wicket, JSF, struts etc.). The only reason is that, we can use Apache Commons FileUpload API in any of the framework. Is there any workaround to do this ? From: Jeremy Thomerson jer...@wickettraining.com To: users@wicket.apache.org Sent: Tuesday, September 8, 2009 12:44:08 PM Subject: Re: Usage of Servlets in Wicket, How ? Maybe if you mention the specific reason(s) that you want to use Apache Commons FileUpload API rather than Wicket's built-in forms and file upload mechanisms, someone on the list will be able to provide you with more help. It seems that the FileUpload API is intended to help you if you have to write servlets to handle forms. But with Wicket, you don't have to do this. And if you use ACFU API, then you lose the rest of Wicket's stateful form handling. -- Jeremy Thomerson http://www.wickettraining.com On Tue, Sep 8, 2009 at 1:04 AM, FaRHaN farhan.ba...@ymail.com wrote: I want to upload files through Commons FIleUpload API. As Commons FileUpload API requires HttpServletRequest for uploading files (e.g. fileItemsList = servletFileUpload.parseRequest(httpServletRequest)). Parsing HttpServletRequest is the necessary step while uploading in Commons FileUpload. I have got httpServletRequest from RequestCycle. e.g. ((ServletWebRequest) getRequest()).getHttpServletRequest() or ((WebRequest)requestCycle.getRequest()).getHttpServletRequest() but this request already being parsed automatically in RequestCycle, before reaching servletFileUpload.parseRequest(httpServletRequest). So, Request is already been parsed... exception occur. That's why i want to use Servlet's doGet(request, response) method for getting HttpServletRequest(without parsing). If not servlets, Is there any other way to handle FileUploading (through Apache Commons API) in wicket ? Thanks... From: Peter Thomas ptrtho...@gmail.com To: users@wicket.apache.org Sent: Tuesday, September 8, 2009 11:39:58 AM Subject: Re: Usage of Servlets in Wicket, How ? Refer this: http://cwiki.apache.org/WICKET/how-to-redirect-to-an-external-non-wicket-page.html If that doesn't help you should briefly explain what your requirement is. There may be a better way to achieve it within Wicket instead of hacking around with servlets. On Tue, Sep 8, 2009 at 10:57 AM, FaRHaN farhan.ba...@ymail.com wrote: but how can we call it from our wicket web page ? From: Jeremy Thomerson jer...@wickettraining.com To: users@wicket.apache.org Sent: Tuesday, September 8, 2009 11:10:49 AM Subject: Re: Usage of Servlets in Wicket, How ? servlets are totally separate from Wicket - write a servlet and add it to your web.xml. See any servlet example on the web (non-Wicket related) for assistance. -- Jeremy Thomerson http://www.wickettraining.com On Mon, Sep 7, 2009 at 11:54 PM, FaRHaN farhan.ba...@ymail.com wrote: Hi, Is there any example in Wicket that uses Servlets (doGet() doPost()). I mean how can we configure Servlets in our wicket application and use doGet(request, response) doPost(request, response) methods. I know web.xml configuration for Servlets but how can we use doGet() doPost() methods. Do we need wicket:ids in Servlets ? Is there any reference for such type of example ? Thanks...
Re: Usage of Servlets in Wicket, How ?
On Tue, Sep 8, 2009 at 12:33 PM, FaRHaN farhan.ba...@ymail.com wrote: I want to make it a separate API for file uploading. So that i can embed it in any of the application regardless of the framework (wicket, JSF, struts etc.). The only reason is that, we can use Apache Commons FileUpload API in any of the framework. Is there any workaround to do this ? This is very interesting. When you say embed it in any of the application regardless of the framework what do you mean ? A tag library ? Suppose you have a multipart form, that contains input fields PLUS a type=file field, to what URL will you POST it and have the input data also bound / handled ? Note that Wicket already has FileUpload built in, that too as a pure Java API so I'm trying to understand your end-goal better. From: Jeremy Thomerson jer...@wickettraining.com To: users@wicket.apache.org Sent: Tuesday, September 8, 2009 12:44:08 PM Subject: Re: Usage of Servlets in Wicket, How ? Maybe if you mention the specific reason(s) that you want to use Apache Commons FileUpload API rather than Wicket's built-in forms and file upload mechanisms, someone on the list will be able to provide you with more help. It seems that the FileUpload API is intended to help you if you have to write servlets to handle forms. But with Wicket, you don't have to do this. And if you use ACFU API, then you lose the rest of Wicket's stateful form handling. -- Jeremy Thomerson http://www.wickettraining.com On Tue, Sep 8, 2009 at 1:04 AM, FaRHaN farhan.ba...@ymail.com wrote: I want to upload files through Commons FIleUpload API. As Commons FileUpload API requires HttpServletRequest for uploading files (e.g. fileItemsList = servletFileUpload.parseRequest(httpServletRequest)). Parsing HttpServletRequest is the necessary step while uploading in Commons FileUpload. I have got httpServletRequest from RequestCycle. e.g. ((ServletWebRequest) getRequest()).getHttpServletRequest() or ((WebRequest)requestCycle.getRequest()).getHttpServletRequest() but this request already being parsed automatically in RequestCycle, before reaching servletFileUpload.parseRequest(httpServletRequest). So, Request is already been parsed... exception occur. That's why i want to use Servlet's doGet(request, response) method for getting HttpServletRequest(without parsing). If not servlets, Is there any other way to handle FileUploading (through Apache Commons API) in wicket ? Thanks... From: Peter Thomas ptrtho...@gmail.com To: users@wicket.apache.org Sent: Tuesday, September 8, 2009 11:39:58 AM Subject: Re: Usage of Servlets in Wicket, How ? Refer this: http://cwiki.apache.org/WICKET/how-to-redirect-to-an-external-non-wicket-page.html If that doesn't help you should briefly explain what your requirement is. There may be a better way to achieve it within Wicket instead of hacking around with servlets. On Tue, Sep 8, 2009 at 10:57 AM, FaRHaN farhan.ba...@ymail.com wrote: but how can we call it from our wicket web page ? From: Jeremy Thomerson jer...@wickettraining.com To: users@wicket.apache.org Sent: Tuesday, September 8, 2009 11:10:49 AM Subject: Re: Usage of Servlets in Wicket, How ? servlets are totally separate from Wicket - write a servlet and add it to your web.xml. See any servlet example on the web (non-Wicket related) for assistance. -- Jeremy Thomerson http://www.wickettraining.com On Mon, Sep 7, 2009 at 11:54 PM, FaRHaN farhan.ba...@ymail.com wrote: Hi, Is there any example in Wicket that uses Servlets (doGet() doPost()). I mean how can we configure Servlets in our wicket application and use doGet(request, response) doPost(request, response) methods. I know web.xml configuration for Servlets but how can we use doGet() doPost() methods. Do we need wicket:ids in Servlets ? Is there any reference for such type of example ? Thanks...
Re: Usage of Servlets in Wicket, How ?
O my dear, i want to make a separate utility method that will take Request and other necessary information as a parameter. just like that: /** Utitlity Method for FileUploading / public static void doUpload(HttpServletRequest request, FileItem fileItem){ if (ServletFileUpload.isMultipartContent(request)){ ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory()); List fileItemsList = null; try { fileItemsList = servletFileUpload.parseRequest(request); } catch (FileUploadException ex) { System.out.println( Exception while Parsing File Upload Request + ex); } String optionalFileName = ; Iterator it = fileItemsList.iterator(); while (it.hasNext()){ fileItem = (FileItem)it.next(); if (fileItem.isFormField()){ String fieldName = fileItem.getFieldName(); String fieldValue = fileItem.getString(); if (fileItem.getFieldName().equals(filename)) optionalFileName = fileItem.getString(); ... } } } } /* End */ And from Wicket Page, call this method when File uploading is required. public void onSubmit(){ doUpload(httpServletRequest, fileItem); } This can happen or not ? The Problem arises while Parsing request ... From: Peter Thomas ptrtho...@gmail.com To: users@wicket.apache.org Sent: Tuesday, September 8, 2009 1:13:22 PM Subject: Re: Usage of Servlets in Wicket, How ? On Tue, Sep 8, 2009 at 12:33 PM, FaRHaN farhan.ba...@ymail.com wrote: I want to make it a separate API for file uploading. So that i can embed it in any of the application regardless of the framework (wicket, JSF, struts etc.). The only reason is that, we can use Apache Commons FileUpload API in any of the framework. Is there any workaround to do this ? This is very interesting. When you say embed it in any of the application regardless of the framework what do you mean ? A tag library ? Suppose you have a multipart form, that contains input fields PLUS a type=file field, to what URL will you POST it and have the input data also bound / handled ? Note that Wicket already has FileUpload built in, that too as a pure Java API so I'm trying to understand your end-goal better. From: Jeremy Thomerson jer...@wickettraining.com To: users@wicket.apache.org Sent: Tuesday, September 8, 2009 12:44:08 PM Subject: Re: Usage of Servlets in Wicket, How ? Maybe if you mention the specific reason(s) that you want to use Apache Commons FileUpload API rather than Wicket's built-in forms and file upload mechanisms, someone on the list will be able to provide you with more help. It seems that the FileUpload API is intended to help you if you have to write servlets to handle forms. But with Wicket, you don't have to do this. And if you use ACFU API, then you lose the rest of Wicket's stateful form handling. -- Jeremy Thomerson http://www.wickettraining.com On Tue, Sep 8, 2009 at 1:04 AM, FaRHaN farhan.ba...@ymail.com wrote: I want to upload files through Commons FIleUpload API. As Commons FileUpload API requires HttpServletRequest for uploading files (e.g. fileItemsList = servletFileUpload.parseRequest(httpServletRequest)). Parsing HttpServletRequest is the necessary step while uploading in Commons FileUpload. I have got httpServletRequest from RequestCycle. e.g. ((ServletWebRequest) getRequest()).getHttpServletRequest() or ((WebRequest)requestCycle.getRequest()).getHttpServletRequest() but this request already being parsed automatically in RequestCycle, before reaching servletFileUpload.parseRequest(httpServletRequest). So, Request is already been parsed... exception occur. That's why i want to use Servlet's doGet(request, response) method for getting HttpServletRequest(without parsing). If not servlets, Is there any other way to handle FileUploading (through Apache Commons API) in wicket ? Thanks... From: Peter Thomas ptrtho...@gmail.com To: users@wicket.apache.org Sent: Tuesday, September 8, 2009 11:39:58 AM Subject: Re: Usage of Servlets in Wicket, How ? Refer this: http://cwiki.apache.org/WICKET/how-to-redirect-to-an-external-non-wicket-page.html If that doesn't help you should briefly explain what your requirement is. There may be a better way to achieve it within Wicket instead of hacking around with servlets. On Tue, Sep 8, 2009 at 10:57 AM, FaRHaN farhan.ba...@ymail.com wrote: but how can we call it from our wicket web
Re: Usage of Servlets in Wicket, How ?
Jeremy Thomerson wrote: servlets are totally separate from Wicket - write a servlet and add it to your web.xml. See any servlet example on the web (non-Wicket related) for assistance. I wouldn't say so, cf Igor sentence in this discussion : http://www.nabble.com/WicketFilter-td25205475.html#a25210469 : map WicketSessionFilter in front of those *servlets*, you will get both Session.get() and Session.get().getApplication(), and Application.get() ++ - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Usage of Servlets in Wicket, How ?
I'm really not sure and can't help on the parsing request problem, although I'm not surprised that attempting to unpack a multipart request twice would result in problems. One thing you could try is understand the form processing life cycle of Wicket - so instead of using onSubmit() (because the request has been already parsed and form fields bound) - you should try over-riding some other method. Not sure, but maybe the process() method is a candidate. I can't help saying that IMO what you are trying is over-complicating things. In fact Wicket actually re-uses code from the apache commons fileupload project, refactored into Wicket classes under: org.apache.wicket.util.upload. Does that make sense? On Tue, Sep 8, 2009 at 1:16 PM, FaRHaN farhan.ba...@ymail.com wrote: O my dear, i want to make a separate utility method that will take Request and other necessary information as a parameter. just like that: /** Utitlity Method for FileUploading / public static void doUpload(HttpServletRequest request, FileItem fileItem){ if (ServletFileUpload.isMultipartContent(request)){ ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory()); List fileItemsList = null; try { fileItemsList = servletFileUpload.parseRequest(request); } catch (FileUploadException ex) { System.out.println( Exception while Parsing File Upload Request + ex); } String optionalFileName = ; Iterator it = fileItemsList.iterator(); while (it.hasNext()){ fileItem = (FileItem)it.next(); if (fileItem.isFormField()){ String fieldName = fileItem.getFieldName(); String fieldValue = fileItem.getString(); if (fileItem.getFieldName().equals(filename)) optionalFileName = fileItem.getString(); ... } } } } /* End */ And from Wicket Page, call this method when File uploading is required. public void onSubmit(){ doUpload(httpServletRequest, fileItem); } This can happen or not ? The Problem arises while Parsing request ... From: Peter Thomas ptrtho...@gmail.com To: users@wicket.apache.org Sent: Tuesday, September 8, 2009 1:13:22 PM Subject: Re: Usage of Servlets in Wicket, How ? On Tue, Sep 8, 2009 at 12:33 PM, FaRHaN farhan.ba...@ymail.com wrote: I want to make it a separate API for file uploading. So that i can embed it in any of the application regardless of the framework (wicket, JSF, struts etc.). The only reason is that, we can use Apache Commons FileUpload API in any of the framework. Is there any workaround to do this ? This is very interesting. When you say embed it in any of the application regardless of the framework what do you mean ? A tag library ? Suppose you have a multipart form, that contains input fields PLUS a type=file field, to what URL will you POST it and have the input data also bound / handled ? Note that Wicket already has FileUpload built in, that too as a pure Java API so I'm trying to understand your end-goal better. From: Jeremy Thomerson jer...@wickettraining.com To: users@wicket.apache.org Sent: Tuesday, September 8, 2009 12:44:08 PM Subject: Re: Usage of Servlets in Wicket, How ? Maybe if you mention the specific reason(s) that you want to use Apache Commons FileUpload API rather than Wicket's built-in forms and file upload mechanisms, someone on the list will be able to provide you with more help. It seems that the FileUpload API is intended to help you if you have to write servlets to handle forms. But with Wicket, you don't have to do this. And if you use ACFU API, then you lose the rest of Wicket's stateful form handling. -- Jeremy Thomerson http://www.wickettraining.com On Tue, Sep 8, 2009 at 1:04 AM, FaRHaN farhan.ba...@ymail.com wrote: I want to upload files through Commons FIleUpload API. As Commons FileUpload API requires HttpServletRequest for uploading files (e.g. fileItemsList = servletFileUpload.parseRequest(httpServletRequest)). Parsing HttpServletRequest is the necessary step while uploading in Commons FileUpload. I have got httpServletRequest from RequestCycle. e.g. ((ServletWebRequest) getRequest()).getHttpServletRequest() or ((WebRequest)requestCycle.getRequest()).getHttpServletRequest() but this request already being parsed automatically in RequestCycle, before reaching servletFileUpload.parseRequest(httpServletRequest). So, Request is already been parsed... exception occur. That's why i want to use Servlet's doGet(request, response) method for getting
Re: Usage of Servlets in Wicket, How ?
servlets are totally separate from Wicket - write a servlet and add it to your web.xml. See any servlet example on the web (non-Wicket related) for assistance. -- Jeremy Thomerson http://www.wickettraining.com On Mon, Sep 7, 2009 at 11:54 PM, FaRHaN farhan.ba...@ymail.com wrote: Hi, Is there any example in Wicket that uses Servlets (doGet() doPost()). I mean how can we configure Servlets in our wicket application and use doGet(request, response) doPost(request, response) methods. I know web.xml configuration for Servlets but how can we use doGet() doPost() methods. Do we need wicket:ids in Servlets ? Is there any reference for such type of example ? Thanks...
Re: Usage of Servlets in Wicket, How ?
but how can we call it from our wicket web page ? From: Jeremy Thomerson jer...@wickettraining.com To: users@wicket.apache.org Sent: Tuesday, September 8, 2009 11:10:49 AM Subject: Re: Usage of Servlets in Wicket, How ? servlets are totally separate from Wicket - write a servlet and add it to your web.xml. See any servlet example on the web (non-Wicket related) for assistance. -- Jeremy Thomerson http://www.wickettraining.com On Mon, Sep 7, 2009 at 11:54 PM, FaRHaN farhan.ba...@ymail.com wrote: Hi, Is there any example in Wicket that uses Servlets (doGet() doPost()). I mean how can we configure Servlets in our wicket application and use doGet(request, response) doPost(request, response) methods. I know web.xml configuration for Servlets but how can we use doGet() doPost() methods. Do we need wicket:ids in Servlets ? Is there any reference for such type of example ? Thanks...
Re: Usage of Servlets in Wicket, How ?
Refer this: http://cwiki.apache.org/WICKET/how-to-redirect-to-an-external-non-wicket-page.html If that doesn't help you should briefly explain what your requirement is. There may be a better way to achieve it within Wicket instead of hacking around with servlets. On Tue, Sep 8, 2009 at 10:57 AM, FaRHaN farhan.ba...@ymail.com wrote: but how can we call it from our wicket web page ? From: Jeremy Thomerson jer...@wickettraining.com To: users@wicket.apache.org Sent: Tuesday, September 8, 2009 11:10:49 AM Subject: Re: Usage of Servlets in Wicket, How ? servlets are totally separate from Wicket - write a servlet and add it to your web.xml. See any servlet example on the web (non-Wicket related) for assistance. -- Jeremy Thomerson http://www.wickettraining.com On Mon, Sep 7, 2009 at 11:54 PM, FaRHaN farhan.ba...@ymail.com wrote: Hi, Is there any example in Wicket that uses Servlets (doGet() doPost()). I mean how can we configure Servlets in our wicket application and use doGet(request, response) doPost(request, response) methods. I know web.xml configuration for Servlets but how can we use doGet() doPost() methods. Do we need wicket:ids in Servlets ? Is there any reference for such type of example ? Thanks...