--
--
You received this message because you are subscribed to the Google Groups "CTJUG Forum" group.
To post to this group, send email to CTJUG...@googlegroups.com
To unsubscribe from this group, send email to CTJUG-Forum...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/CTJUG-Forum
For the ctjug home page see http://www.ctjug.org.za
For jobs see http://jobs.gamatam.com/
---
You received this message because you are subscribed to the Google Groups "CTJUG Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ctjug-forum...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
I have used Struts and Faces in the past and had some terrible experiences when I had to achieve something outside the scope it was intended for. This lead to some hackish code and I ended up dropping the frameworks. Also I do not want to include Spring so I can use one of its features.
App servers have other functionality I would like to use if necessary. I do a lot of small prototyping projects and I would like to keep my code as portable as possible, web and app server compatible.
Can we please get back to the original question? I am currently not looking for a framework, because my original question is a single part of a much larger project I am dabbling around with. The end result would be my own framework.
From: ctjug...@googlegroups.com [mailto:ctjug...@googlegroups.com] On Behalf Of Yusuf Jakoet
Sent: 20 August 2013 10:11 AM
To: ctjug...@googlegroups.com
Subject: Re: [CTJUG Forum] Bypassing Servlets - What are the implications involved?
>> I try and stay away from frameworks like spring and faces etc due to their limitations and overheads.
--
--
You received this message because you are subscribed to the Google Groups "CTJUG Forum" group.
To post to this group, send email to
You shouldn't have any issues.
Most web frameworks use a Filter to dispatch to custom controllers (Struts 2, Resteasy, off the top of my head), because it's more flexible than dispatching from a Servlet. I've written a web framework that does the same.
As long as you're returning a proper response, you're fine. It's generally easier if you force users to put your filter as the last one in the chain. So you're totally compatible with other filters, as long as you respect the chain.
You could even combine it with the GuiceFilter found in Guice-Servlet (or a CDI equivalent) to get DI for free. That's something I've done in the past.
--
> To achieve this I had to skip chaining in my filter.
I'd missed this point. Could you elaborate on the reasons? A gzip filter, or even one that wraps the request or response (for example, I often use a filter that changes the http method based on a field in a form) shouldn't be a problem.
Thanks for the feedback Moandji, I have set up a basic prototype doing the following:
Basic Example of implementation:
@Serv("/testserv")
public class TestMe {
@AjaxJson("jsontest")
public void getUsers(Rex rex){
rex.out("outcome", "success");
}
@AjaxText("texttest")
public String getUsers(Rex rex){
return "Success";
}
@WMethod("testwmethod")
public String getUsers(Rex rex){
rex.out("outcome", "success");
return "/index.jsp";
}
}
The @Serv annotation basically contains the requests servletpath you would like to map the object to
The @AjaxJson annotation writes out all the Requests Attributes as a JSON Object via GSON (Thread safety confirmed)
The @AjaxText annotation writes the returned String to the Responses Out
The @WMethod annotation acts like a standard servlet returning the path to the jsp which a request dispatcher dispatches to
The values specified by all the web methods above are the attribute names in a request.
The Rex object passed to these methods is just a wrapper object containing the HttpServletrequest, HttpServletResponse and an EntityManager for conveniently getting objects from the database without filtering through request parameters (validation done on parameters first ofcourse).
The out method on the Rex object basically just calls the request.setAttribute so I could swop out the annotations and make basic changes if I require the methods to do something else.
The annotation mappings and their respective Classes and Methods are cached via a ServletContextListener at startup.
If a request mapping is not found in these custom mappings it just proceeds through the filter chain as per normal.
From: ctjug...@googlegroups.com [mailto:ctjug...@googlegroups.com] On Behalf Of Moandji Ezana
Sent: 20 August 2013 11:15 AM
To: ctjug...@googlegroups.com
Subject: Re: [CTJUG Forum] Bypassing Servlets - What are the implications involved?
You shouldn't have any issues.
I'll avoid debating any of the design... ;).
Still, I'm curious to know what part of this required breaking the filter chain?
As an aside, I stopped writing my own web frameworks when JAX-RS 2 came out. It's surprisingly good for a Java web framework.
I hope on converting some of this functionality to Rhino JS so I can create a front end where I can modify my “servlets” directly from there and then have it cached with it’s CompiledScript counterparts.
A system which allows for adjustments while its running kind of thing, also learning a lot as I go along.
Oh and I am breaking the filter chain, because it is writing to the response.
--
Continuing the chain at that point would cause an exception to be triggered if it eventually finds no static web resources. I do not believe it will serve much of a purpose, because at that point a response would have already been generated.
I have also run some tests to compare the access speeds and this method seems to be on par with a standard servlets execution and lookup.
Please note however my tests only contained a few web methods and larger applications would contain many more.
From: ctjug...@googlegroups.com [mailto:ctjug...@googlegroups.com] On Behalf Of Andrew van der Westhuizen
Sent: 22 August 2013 08:06 AM
To: ctjug...@googlegroups.com
Subject: Re: [CTJUG Forum] Bypassing Servlets - What are the implications involved?
Can you not call doFilter first and put the code after the call? Effectively making it a post chain operation.