|
»
servlet question
|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
servlet questionHello everyone, I am trying to find whether sth is possible with RIFE or not. Say I want to use a servlet like below ----- public class Test extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { PrintWriter out = res.getWriter(); out.println("Hello, world!"); out.close(); } } ----- which is fairly simple. I added this to web.xml and it works ok. I can also put it under /admin/hello. What I want to do is to use the authentication mechanism of RIFE so that a user can not reach my servlet under /admin unless he is logged in. Thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "rife-users" group. To post to this group, send email to rife-users@... To unsubscribe from this group, send email to rife-users+unsubscribe@... For more options, visit this group at http://groups.google.com/group/rife-users?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: servlet questionHi, Actually this should work since RIFE is setup as a filter, so can be 'above' your servlet. For this to work though, you'll probably have to setup a element that you bind to the same URL and just call 'defer()' inside the processElement method. Without this, RIFE will not consider the URL of the servlet as one of the URLs that it should process. It's probably easier if you setup this element with a wildcard URL to prevent you having to set this up for each servlet like this. Hope this helps, Geert On 23 Nov 2008, at 01:01, dk wrote: > > Hello everyone, > > I am trying to find whether sth is possible with RIFE or not. > > Say I want to use a servlet like below > ----- > public class Test extends HttpServlet > { > public void doGet(HttpServletRequest req, HttpServletResponse res) > throws ServletException, IOException > { > PrintWriter out = res.getWriter(); > > out.println("Hello, world!"); > out.close(); > } > } > ----- > which is fairly simple. I added this to web.xml and it works ok. I can > also put it under /admin/hello. > > What I want to do is to use the authentication mechanism of RIFE so > that a user can not reach my servlet under /admin unless he is logged > in. > > Thanks -- Geert Bevin Terracotta - http://www.terracotta.org Uwyn "Use what you need" - http://uwyn.com RIFE Java application framework - http://rifers.org Music and words - http://gbevin.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "rife-users" group. To post to this group, send email to rife-users@... To unsubscribe from this group, send email to rife-users+unsubscribe@... For more options, visit this group at http://groups.google.com/group/rife-users?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: servlet questionThank you for the answer Geert I will look into it On Nov 23, 10:28 am, Geert Bevin <gbe...@...> wrote: > Hi, > > Actually this should work since RIFE is setup as a filter, so can be > 'above' your servlet. > > For this to work though, you'll probably have to setup a element that > you bind to the same URL and just call 'defer()' inside the > processElement method. Without this, RIFE will not consider the URL of > the servlet as one of the URLs that it should process. It's probably > easier if you setup this element with a wildcard URL to prevent you > having to set this up for each servlet like this. > > Hope this helps, > > Geert > > On 23 Nov 2008, at 01:01, dk wrote: > > > > > > > Hello everyone, > > > I am trying to find whether sth is possible with RIFE or not. > > > Say I want to use a servlet like below > > ----- > > public class Test extends HttpServlet > > { > > public void doGet(HttpServletRequest req, HttpServletResponse res) > > throws ServletException, IOException > > { > > PrintWriter out = res.getWriter(); > > > out.println("Hello, world!"); > > out.close(); > > } > > } > > ----- > > which is fairly simple. I added this to web.xml and it works ok. I can > > also put it under /admin/hello. > > > What I want to do is to use the authentication mechanism of RIFE so > > that a user can not reach my servlet under /admin unless he is logged > > in. > > > Thanks > > -- > Geert Bevin > Terracotta -http://www.terracotta.org > Uwyn "Use what you need" -http://uwyn.com > RIFE Java application framework -http://rifers.org > Music and words -http://gbevin.com You received this message because you are subscribed to the Google Groups "rife-users" group. To post to this group, send email to rife-users@... To unsubscribe from this group, send email to rife-users+unsubscribe@... For more options, visit this group at http://groups.google.com/group/rife-users?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: servlet questionI have one further question related to this topic Can I use my db manager which extends DbQueryManager in my servlet. My servlet doesnt extends from Element by the way. I tried it but it throws null pointer exception within the constructor of dbmanager. Thanks dogan On Nov 23, 10:28 am, Geert Bevin <gbe...@...> wrote: > Hi, > > Actually this should work since RIFE is setup as a filter, so can be > 'above' your servlet. > > For this to work though, you'll probably have to setup a element that > you bind to the same URL and just call 'defer()' inside the > processElement method. Without this, RIFE will not consider the URL of > the servlet as one of the URLs that it should process. It's probably > easier if you setup this element with a wildcard URL to prevent you > having to set this up for each servlet like this. > > Hope this helps, > > Geert > > On 23 Nov 2008, at 01:01, dk wrote: > > > > > > > Hello everyone, > > > I am trying to find whether sth is possible with RIFE or not. > > > Say I want to use a servlet like below > > ----- > > public class Test extends HttpServlet > > { > > public void doGet(HttpServletRequest req, HttpServletResponse res) > > throws ServletException, IOException > > { > > PrintWriter out = res.getWriter(); > > > out.println("Hello, world!"); > > out.close(); > > } > > } > > ----- > > which is fairly simple. I added this to web.xml and it works ok. I can > > also put it under /admin/hello. > > > What I want to do is to use the authentication mechanism of RIFE so > > that a user can not reach my servlet under /admin unless he is logged > > in. > > > Thanks > > -- > Geert Bevin > Terracotta -http://www.terracotta.org > Uwyn "Use what you need" -http://uwyn.com > RIFE Java application framework -http://rifers.org > Music and words -http://gbevin.com You received this message because you are subscribed to the Google Groups "rife-users" group. To post to this group, send email to rife-users@... To unsubscribe from this group, send email to rife-users+unsubscribe@... For more options, visit this group at http://groups.google.com/group/rife-users?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: servlet questionCan you paste the exact exception and some code snippets that show how to use the DbQueryManager? On 28 Nov 2008, at 01:52, dk wrote: > > I have one further question related to this topic > > Can I use my db manager which extends DbQueryManager in my servlet. My > servlet doesnt extends from Element by the way. > > I tried it but it throws null pointer exception within the constructor > of dbmanager. > > Thanks > > dogan > > > > On Nov 23, 10:28 am, Geert Bevin <gbe...@...> wrote: >> Hi, >> >> Actually this should work since RIFE is setup as a filter, so can be >> 'above' your servlet. >> >> For this to work though, you'll probably have to setup a element that >> you bind to the same URL and just call 'defer()' inside the >> processElement method. Without this, RIFE will not consider the URL >> of >> the servlet as one of the URLs that it should process. It's probably >> easier if you setup this element with a wildcard URL to prevent you >> having to set this up for each servlet like this. >> >> Hope this helps, >> >> Geert >> >> On 23 Nov 2008, at 01:01, dk wrote: >> >> >> >> >> >>> Hello everyone, >> >>> I am trying to find whether sth is possible with RIFE or not. >> >>> Say I want to use a servlet like below >>> ----- >>> public class Test extends HttpServlet >>> { >>> public void doGet(HttpServletRequest req, HttpServletResponse >>> res) >>> throws ServletException, IOException >>> { >>> PrintWriter out = res.getWriter(); >> >>> out.println("Hello, world!"); >>> out.close(); >>> } >>> } >>> ----- >>> which is fairly simple. I added this to web.xml and it works ok. I >>> can >>> also put it under /admin/hello. >> >>> What I want to do is to use the authentication mechanism of RIFE so >>> that a user can not reach my servlet under /admin unless he is >>> logged >>> in. >> >>> Thanks >> >> -- >> Geert Bevin >> Terracotta -http://www.terracotta.org >> Uwyn "Use what you need" -http://uwyn.com >> RIFE Java application framework -http://rifers.org >> Music and words -http://gbevin.com > > -- Geert Bevin Terracotta - http://www.terracotta.org Uwyn "Use what you need" - http://uwyn.com RIFE Java application framework - http://rifers.org Music and words - http://gbevin.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "rife-users" group. To post to this group, send email to rife-users@... To unsubscribe from this group, send email to rife-users+unsubscribe@... For more options, visit this group at http://groups.google.com/group/rife-users?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: servlet questionSure here here are the related classes This is my element that defer public class GetParentNames extends Element { public void processElement() { System.out.println("/getParentNames"); defer(); } } and here is the servlet that works after the element above public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { PrintWriter out = res.getWriter(); StudentManager manager = new StudentManager(); manager.display(new DbBeanFetcher<Student>(manager.getDatasource(), Student.class) { public boolean gotBeanInstance(Student friend) { System.out.println(friend.getName() + " " + friend.getSurname()); return true; } }); out.println("Test completed."); out.close(); } And the manager public class StudentManager extends DbQueryManager { public StudentManager() { super(Datasources.getRepInstance().getDatasource (Config.getRepInstance().getString("DATASOURCE")));//here is where I got the exception } .... public void display(DbRowProcessor processor) { Select select = new Select(getDatasource()).from (TABLE_NAME_STUDENT).fields(Student.class).orderBy("name"); executeFetchAll(select, processor); } } And finally the exception is as follows Nov 28, 2008 5:01:38 PM org.mortbay.jetty.servlet.ServletHandler handle WARNING: /admin/getParentNames: java.lang.NullPointerException at backend.dbmanagers.StudentManager.<init>(StudentManager.java:28)// here is the call to super contructor at testutil.Test.doGet(Test.java:22) at javax.servlet.http.HttpServlet.service(HttpServlet.java:596) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) On Nov 28, 8:53 am, Geert Bevin <gbe...@...> wrote: > Can you paste the exact exception and some code snippets that show how > to use the DbQueryManager? > > On 28 Nov 2008, at 01:52, dk wrote: > > > > > > > I have one further question related to this topic > > > Can I use my db manager which extends DbQueryManager in my servlet. My > > servlet doesnt extends from Element by the way. > > > I tried it but it throws null pointer exception within the constructor > > of dbmanager. > > > Thanks > > > dogan > > > On Nov 23, 10:28 am, Geert Bevin <gbe...@...> wrote: > >> Hi, > > >> Actually this should work since RIFE is setup as a filter, so can be > >> 'above' your servlet. > > >> For this to work though, you'll probably have to setup a element that > >> you bind to the same URL and just call 'defer()' inside the > >> processElement method. Without this, RIFE will not consider the URL > >> of > >> the servlet as one of the URLs that it should process. It's probably > >> easier if you setup this element with a wildcard URL to prevent you > >> having to set this up for each servlet like this. > > >> Hope this helps, > > >> Geert > > >> On 23 Nov 2008, at 01:01, dk wrote: > > >>> Hello everyone, > > >>> I am trying to find whether sth is possible with RIFE or not. > > >>> Say I want to use a servlet like below > >>> ----- > >>> public class Test extends HttpServlet > >>> { > >>> public void doGet(HttpServletRequest req, HttpServletResponse > >>> res) > >>> throws ServletException, IOException > >>> { > >>> PrintWriter out = res.getWriter(); > > >>> out.println("Hello, world!"); > >>> out.close(); > >>> } > >>> } > >>> ----- > >>> which is fairly simple. I added this to web.xml and it works ok. I > >>> can > >>> also put it under /admin/hello. > > >>> What I want to do is to use the authentication mechanism of RIFE so > >>> that a user can not reach my servlet under /admin unless he is > >>> logged > >>> in. > > >>> Thanks > > >> -- > >> Geert Bevin > >> Terracotta -http://www.terracotta.org > >> Uwyn "Use what you need" -http://uwyn.com > >> RIFE Java application framework -http://rifers.org > >> Music and words -http://gbevin.com > > -- > Geert Bevin > Terracotta -http://www.terracotta.org > Uwyn "Use what you need" -http://uwyn.com > RIFE Java application framework -http://rifers.org > Music and words -http://gbevin.com You received this message because you are subscribed to the Google Groups "rife-users" group. To post to this group, send email to rife-users@... To unsubscribe from this group, send email to rife-users+unsubscribe@... For more options, visit this group at http://groups.google.com/group/rife-users?hl=en -~----------~----~----~----~------~----~------~--~--- |
| Free embeddable forum powered by Nabble | Forum Help |
