How to get the resources (Images/JSP/CSS) and their properties which got involved in Servlet Response - servlets

Once I got the servlet response,I need to check what are the resources involved in it.
Like the below
1) What is JSP/HTML's relative path,name which is coming as a servlet response
2) What is the Images/CSS/Scripts involved in the response view files (JSP/HTML)
Can filter be useful at this point or any other approach, if it is then how? Any guidelines will be great help.

Related

RESTful API: Is it more practical to pass in parent resource locators in the request body instead of in the URI?

Suppose we have are building a REST API for a job listings app where a user can apply for a job.
Instead of making JobApplication a nested URI resource like so:
It would be made a top-level resource:
Of course, in the case of the latter, the JobVacancy's id is still included in the request but is passed through the request body instead of the URI.
Why the latter approach? Because it saves the client the inconvenience of having to know the parent resource's id for 3 of the routes.
I believe that in the end, this is just a matter of standard. Both solutions will work fine, however, the first approach is more readable closer to the real-world operations, the applications are always related to some job vacancies.
Moreover, you need to consider if, in your system, you always access the applications starting from a job vacancy. If this is true, I believe that the first approach is much more clear, because the relation of dependencies between the two entities is clearly expressed in the signature of the method.

Are other HTTP methods necessary?

I've been trying to find a simple (or heck even a complex answer to this), so I hope someone can shed some light on a curiosity I've got about http requests.
I'm building a web service and will be making HTTP requests to get and update information.
I've built a few things like this in the past so I'm familiar with GET, and POST; but I came across a few other methods like PUT, and DELETE and not many pages have information on them, to me they seem like the POST method just with a different name.
So my question(s) is:
1) Is it really necessary to use PUT, DELETE or is POST still just as useful?
2) If they are (or aren't necessary) then what makes them necessary i.e. when would they be used/preferred over POST?
It depends how you want to design your URLs. If I'm implementing a REST API, I like to use REST URLs for "nouns" (entities) of my application, and use the various HTTP methods as different "verbs" to act on those entities.
Usually I use them as following:
POST : to create a new record
GET : to retrieve one or more records
PUT : to update a record
DELETE : to delete a record
For example, see this article about more information about REST API design.
https://hackernoon.com/restful-api-designing-guidelines-the-best-practices-60e1d954e7c9

Check if URL targets Action (vs. file/etc)

I'm trying to determine the best way to determine if a URL (as seen in the global.asax) is for an action. I'm wanting to exclude EVERYTHING else...i.e. a request to a bundle would fail as well as a request for a file.
It seems clunky and dirty to check to make sure the request isn't for a file/directory/bundle/etc. I'm hoping to be able to instead JUST check to see if it's an action, but I'm having issues coming up with what that test would look like.
Just FYI, in case it's relevant. I'm working on some internationalization of a site and I'm needing to filter the Request objects so that I only fiddle with the one for the initial request.

how to handle download request from a WebView using WebResourceRequestFilter blackberry Cascades

i want to handle any download request coming from Webview. how it is possible ? the documentation https://developer.blackberry.com/native/reference/cascades/bb__cascades__webresourcerequestfilter.html and https://developer.blackberry.com/native/reference/cascades/bb__cascades__webdownloadrequest.html are describing the parameters but couldn't figure out how to do it.
Your question is not clear on what you don't understand. Remember this is not a training forum, the idea is that you should try things, review the documentation and then ask specific questions to get the best out of a forum.
Moreover it is not clear whether you are trying to handle the download request at the Server, or capture the request before the download attempt leaves the BB.
I'm going to assume you want to display a web page on the BlackBerry but make sure that any resource requests that the page generates, are filtered by your program, so that you can supply the data (assuming you have it).
I implemented something like this a while ago and remember that it was not simple to figure out what was going on, but I played with it a bit and it all made sense.
I don't remember using WebDownloadRequest and can't really see how it helps in this case.
The key is WebResourceRequestFilter. You create your own WebResourceRequestFilter making sure you implement the required methods. Then you use WebPage::setNetworkResourceRequestFilter(WebResourceRequestFilter*) to make sure the webpage will ask your WebResourceRequestFilter for its resources. The first method the web page invokes is filterResourceRequest(), and the return from this invocation determines which other methods in your WebResourceRequestFilter, the Webage will invoke.
I suggest you implement a WebResourceRequestFilter, put some debugging in filterResourceRequest(), but always return FilterAction Accept, which means the web page will use its normal processing to obtain the resources. Then try various other FilterAction return values and see what happens...

Web caching and Spring WebMVC

Is this a duplicate of 11427666? Not quite.
Our JSP pages take quite a long time to render (> 200ms) because of many many translated fragments and the resulting calls to the message source. I can imagine to remove the moving parts (load them with AJAX afterwards), so the pages will be static – except from the locale that still depends on the user that is logged in.
I looked at Ehache and web caching which looks promising. However, it is a simple filter, depending on the URL only.
How would I combine the two? Interceptor, filter?
Since you can't use the standard servlet filter due to the need for session data, seems to me that you'd want to use some sort of taglib within your JSP in order to cache the entire page...resulting in 1 single cache lookup based on "url+locale".
In your JSP, that'd be something like:
<cache:ehcache>
you page text...more text...
message bundle lookup etc...
more text
etc...
</cache:ehcache>
The bad news: I don't think this taglib exists already...
But the good news: I don't think it'd be too hard at all to build.
And if you do, you could share it, as I'm sure there are many others who'd be interested.
Hope that helps a bit.
Rendering of jsp static fragments should be almost instantaneous as these are compiled to byte code. Is the 200ms rendering time from your local machine or from a server?
Here are a few approaches to integrate the two:
Getting an EhCache instance with Spring... intelligently
Caching Methods with Spring 3 Annotations
Using Spring and BigMemory Go
References
Ehcache 2.6.x Documentation (PDF)
ehcache-spring-annotations github repo

Resources