Jack Mutansan

Ranch Hand
+ Follow
since Jul 10, 2017
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 Jack Mutansan

Claude Moore wrote:If you specify GET method with @Requestmapping, the Rest endpoint will respond only to GET requests. Are you really sure you are POSTing a request???
What happens using curl - for example ?

Hi, I thought I was supposed to use "GET" since this is getting student name.  So it works fine when you use "GET" and view it from URL on a browser.  

What confused me was --- When I use Postman tool, when I specify "GET" I couldn't get results.  But when I specify "POST" it returns data.  I don't understand why.
3 weeks ago

Above is a simple method in a @RestController.  I found when I access this via a browser "http://localhost:8080/xxx/getStudent?classID=2"; it works but only works when RequestMethod is "GET".  if I change it to "Post" it doesn't work on browser

However, the interesting thing is, when I use Google Postman tool,  when I specify "GET", I don't get the list of names, but when I use "POST" I get the results (same results as I use "GET" on browser).

Does anybody know why it behaves differently ?
3 weeks ago
I don't know if anybody has similar problem as I am having -- When I work on or trouble shoot a particular problem, I actually can concentrate well and sometimes an hour could just pass easily and I didn't notice.  But when I sit down to learn something like new a tutorial, I realize I just can't concentrate well and easily gets impatient, even though the tutorial is actually pretty nice created with good stuff that I want to learn.   Does anybody have similar problem and want to share how to improve ?
3 weeks ago
ACEGI was the earliest Spring security model, it gradually replaced by spring security after spring 3.  Wondering if newer spring version compatible with ACEGI ?
3 weeks ago

above is a typical control code.  But I saw some older version spring code like

above is from book "Spring REceipes A problem-solution approach" by Gary Makin 2008.  A very old book.

But  old version seems making more sense to me since it takes request/response as input.  The new version directly takes a ModelAndView as input , where does it get request and response ?
3 weeks ago
Using JDBC Connection, Statement, Resultset for SQL server.    Do I need to do "connection.setAotiCommit(true)" if the code is just about SELECT a bunch of rows ?  

Paul Clapham wrote:I'm using the JEE version of Eclipse, version Mars. (Yes, I know I should spend some time to update to the latest version.) Anyway I just created a Dynamic Web Project and the source folder was by default named "src".

But "JavaSource" rings a (distant) bell for me -- maybe when I was using IBM RAD at my previous place of work, several years ago, I had a web project with that folder for the Java source. Not sure though after all these years.

somehow I lost track of this thread and finally found it ! Yes, the "Dynamic Web Project" I created from Eclipse source folder is named "src".  But if you look closely, this "src" is under a folder named "Java Resources".  But, this "Java Resources" seems not to be a real folder in local file system, since  when I right click on "src" and view its "properties" its location path doesn't include a "Java Resources" folder in the middle.  Thus "Java Resources" is more like a logical name appearing on Eclipse GUI but not on file system.

Now I have a separate question -- If I want to create a directory called "resources" to put some property files and want it is under application's classpath, should I create a "resources" folder directly under this logic folder "Java Resources" or under directory "src" ?
4 weeks ago
Thanks Tim.  Your detailed explanation indeed helped me better understand the reason.   Just want mention that, the old code I saw working using getClassLoader() was also a web application where one of its controller invokes a standalone java, which gets the property using getClassLoader().getResourceAsStream().  So I guess I shouldn't say it was a standlone java..   I saw it works, but when I created a separate practice mini web application and do the same thing (using getClassLoader()), it doesn't work for me.   But anyway, now I realize that, for web application it is more reliable and predictable to use ServletContext() to getResourceAsStream since it is about the application itself without involving comlicated classloader.
4 weeks ago
I tried ServletContext and its getResourceAsStream() works with "/WEB-INF/name.properties",  thanks !

However, in some old java code I worked on and maintained, in some standalone java (inconvenient to access ServletContext), I do see it uses getClass().getClassLoader().getResourceAsStream("/WEB-INF/fileName.properties")..  And it worked fine.   So I am just wondering if this getClassLoader().getResourceAsStream  sort of works unstably, i.e. sometime it does, sometime not..  Maybe it works when the .war was unpacked (which was the case when those old code deployed) on server ? I don't know.
4 weeks ago
I use Eclipse to create a java Dynamic Web Project.  Then "configure to maven" project.  Then I created a "source folder" named "resources" and put a property file there.   I have a controller, inside the controller I read a property file

it works fine.  I am able to read data from property file.  I guess it is because "name.properties" is put in a source folder so it is in classpath automatically.

Now I moved the property file to folder WEB-INF/

I tried "/WEB-INF/name.properties" and "WEB-INF/name.properties", no luck.  "inputStream" is null.

Although we usually put it under reources/ folder, but since I use .getResourceAsStream, it should be Ok to put it under WEB-INF/ right ?  Can someone help tell me what I missed here ?
Thank you.
1 month ago
I found that when I create an Eclipse "Dynamic Web Project", sometimes it generates a folder called "JavaSource" but some generate "src".  Anybody has any idea why ?
5 months ago
1. I import a remote repository project to my local eclipse workspace and named it "MyProject"

2. I copy and paste this "MyProject" into "MyProject2"

3. I make changes on "MyProjct2" and then I delete "MyProject2".  
Question is: after I delete "MyProject2",  will it affect "MyProject" and the codes on the repository site where I initially imported from ?

7 months ago
Anybody knows any good Jasper report forum (out of javaranch) ?
1 year ago
I found that I kept getting "null" from request.getUserPrincipal() or request.getRemoteUser().  I added

it started returning values.  The application is an internal web application and users only access it from our internal internet.  Can somebody help explain ?
1 year ago