Win a copy of Terraform in Action this week in the Cloud forum!

Zahro Alfelpha

Ranch Hand
+ Follow
since May 24, 2016
Zahro likes ...
Spring Java Linux
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Zahro Alfelpha

First of all it's weird to me that they even call it "Legacy" projects. So because it isn't Spring Boot it's legacy? Whatever. Anyways, The templates for Spring MVC seem to be terribly outdated. Choosing a new Spring MVC Project results in a Spring 3.2.2 project using Java 5. It says the url for the template is I can't seem to find the url to use a more up to date template. Can anyone point me in the right direction? (and no I don't mean a link to download IntelliJ lol). I am using Eclipse Neon 3.
4 years ago
I assume you're looking for something like this
4 years ago

Joe Ess wrote:I would recommend using the standard​ JEE security mechanism built into the servlet container

Thanks, I will look into this.
4 years ago

Joe Ess wrote: Exactly what do you want to accomplish with annotations?

I'm using a servlet filter to prevent unauthorized access to some pages. Currently the list of protected paths is kept in a list of strings and the filter compares the request path to the list.

What I would like to do is create an annotation to put on the Action classes themselves, and then simply check for that annotation on whichever Action is passing through the filter.
4 years ago

Joe Ess wrote:Don't use Struts 1.x unless you have a very good reason.

Unfortunately that is beyond my control at the moment but trust me I'd love to not be using Struts at all.

Joe Ess wrote:it appears that the Struts 1.x API works the same way as far as action context is concerned.

I'm not sure this is the case. I am finding no static getActionContext method in org.apache.struts.chain.contexts.ServletActionContext

I really appreciate your replies.
4 years ago

Joe Ess wrote:

Zahro Alfelpha wrote:

Bear Bibeault wrote:Fixed

thanks! so is it even possible to edit/delete posts?

You should be able to edit your own posts.  I don't know if you can edit titles (I can, but I'm a moderator).
The reason your code isn't working is because you are creating your own context object instances instead of obtaining those that are available via the framework.  To get the current ServletActionContext instance, you should use the getActionContext method.

This is the part where I cry and tell you that I'm using Java 5 and Struts 1.3....
4 years ago

Bear Bibeault wrote:Fixed

thanks! so is it even possible to edit/delete posts?
4 years ago
I am using a servlet filter where I am trying to get action associated with the current request.

Relevant sections of my filter:

My problem is that `action` ends up being null. Both of the context variables get populated with a value, but for some reason it cant find the action. Any ideas? Thanks!
4 years ago

Paul Clapham wrote:You're assuming that if Session A makes a request, and then subsequently Session B makes a request, then those two requests must be processed by different threads. I don't see why that should be the case: once Session A's request is finished, the thread which processed it should become available (via the thread pool) to be used by any subsequent request.

Thanks Paul, I ended up figuring it out. It turns out that there is a servlet filter whose job it is to sync the custom context to the active session. this custom context filter was declared in web xml after the filters that use the custom context, so this explains why the error was only happening inside of the filters :)
4 years ago
I am working on a messy Struts 1 application that makes use of a custom context class to store values throughout the application. Basically it is only used to store session scope variables. I guess the reason that this custom class is used is so that other classes which do not have access to the http session can still get and set the session variables.

Anyways, for the most part this works just fine. The custom context is used throughout the Actions and service classes to share variables with no problem. However, I just discovered that things do not work out so nicely using this custom context inside of an Http Filter! It appears that it randomly will pull the value from a different session. And by session, I actually mean thread, since this custom context uses ThreadLocale to do it's dirty work.

Take a look

Again, this seems to work just fine and dandy inside every other class other than a filter. Let me show you the filter where it messes up.

When the custom context is used to grab the user in the doFilter method, it will randomly grab the user object from another logged in user. Obviously not a good situation!

The only time this happens is after some activity from a different logged in user. I could sit there all day and keep refreshing user A's session and there wouldn't be an issue. However, after taking some action as user B and then refreshing user A's session again, it will usually be swapped. But then if I refresh user A's session again, things are back to normal.

I've noticed this happens extremely more frequently when the application is actually deployed to a remote development tomcat server. It still happens when running locally, but not nearly as often as when deployed remotely. It happens almost 100% of the time remotely.

I have examined the session variable inside of the filter, and there doesn't appear to be an issue with the session itself. I have confirmed that the session id is still correct even when the incorrect user is pulled from the ThreadLocale variable.

Can anyone help me out? Thanks.
4 years ago
I am trying to use Jersey to provide a simple web service for my struts application.

When I call the client action I get the following error

   Message: GET http://localhost:8080/shumer/rest/employee/get returned a response status of 404

servlet declaration in web.xml

Server resource

Client action

I have tried this with and without the `/get` and the end of the resource url, and with and without a leading `/` in the EmployeeResource @Path annotation. My guess is that there is somewhere I have to declare where my resources are lcoated at in order for the Jersey servlet to handle them, but I can't figure it out. A point in the right direction would be much appreciated.

4 years ago
I have a web application that uses Struts and iBatis. I am running the application inside of a tomcat server within Eclipse. Whenever I run a `SELECT` query that returns many rows, I get a `java.lang.OutOfMemoryError`. If I limit the amount of rows returned, then it doesn't happen. I have searched on this site for similar issues, and most of the answers talk about increasing the java heap size which I have done in the `eclipse.INI` file by setting it to 2048 via `-Xmx2048m`. I have also seen some people suggest changing the way in which jdbc handles the result set, but I have been unable to find how to do that using iBatis. Here is what my database settings look like

Full Stack Trace