This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages forum!

vishnu priyag

Ranch Hand
+ Follow
since Aug 29, 2021
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
2
Received in last 30 days
0
Total given
12
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by vishnu priyag

Hi,

I am trying to run the simple javascript code in new window opened. But browser is not requesting the file and the javascript is not running.
May i know why?

new_window.html




new_window.js



Here is the document in new window.


It can be seen that script tag is properly inserted. But javascript is not running.

Can someone please point out what's the problem here.

Thanks in advance.
Hi,

I have googled about this well, but couldn't able to get the answer.



In the above handler method, i didn't pass the order object to model, but it is still accessible in orderForm view.
How this is happening without @ModelAttribute / model.addAttribute("order", order);

is every object similar to order in handler method parameters is automatically available in model?
Can someone please clarify my doubt

Thanks in advance.
1 month ago
Thanks for the answer.

Please correct me if I am wrong, container frames the ServletContext  by reading web.xml content, so that it can use it at application runtime.
Container uses it to find the relevant mapping servlet, filters, listeners.
Application code uses it to share the common data by adding as attributes in ServletContext.

If ServletContext is being formed from the configuration in web.xml, then how come it has reference to files using getResource() which are not part of web.xml i.e some static files, static html (present outside WEB-INF).
What application code looks in servletContext apart from files, attributes, parameters?
Who else will use the ServletContext and what purposes?

Thanks.
1 month ago
Yeah got it, I said one per JVM considering one web app per JVM.
Can someone please clear my doubts regarding ServletContext
1 month ago
Hi,

I am aware ServletContext is one per JVM and is used to set attributes that are visible to whole application.
But there is also a definition for ServletContext - It provides interface between Container and Servlet. But i didn't understand what this exactly meant.

And also, in the ServletContext interface I noticed methods for adding Servlet, Filters, Listeners. But why is this?

I wanted the role of ServletContext in web container. Can someone please provide the info.

Thanks in Advance.
1 month ago
Hi,

Consider this example





I have this doubt since very long when people say java based configuration is better than xml.
In the above example, when i want to change the dependency of employeeDao from JDBC to Hibernate, i need to update the @Qualifier("hibernate"),
and then have to compile the java class and then run it.
We moved from normal java new keyword to DI to decouple the dependencies and change the dependencies without change in code. But in above scenario, change in java code and recompiling is needed.

But xml configuration avoids this recoompilation.
Then why people still prefer annotation based over xml?

Does change in annaotation data not require compilation?


Thanks in advance.




1 month ago
Tomcat is the web container that is being used, and no proxy at least for QA server.
2 months ago
Okay got it. But i have access to QA server, can you please guide me where do i need to make changes
2 months ago
Hi,

I know post can't be performed through browser, in my case, it is done as part of the application.
I can't change the query string parameters to body, cause it's working fine, only in this case of data, it is working weirdly.

And also with this data, it is working fine when i am running application in local, one of the QA servers, but this is the issue that is occurring in other QA server and Production.

I am really not understanding why it's happening like this.
Can you please suggest some way to find the root cause other than shifting the data to body.
2 months ago
But, when i am running application in local, it is working fine.
2 months ago
Yes, it worked even with new line character like:

Tell me a little about your "Wish List" so I can refine this search for you.

Call
, but not working with

Tell me a little about your "Wish List" so I can refine this search for you.

Call m


i.e not working for any extra character after 'm'
2 months ago
In the part of query parameters, and this is how it looks like
localhost:8080/xhr/save?name=priya&id=6625&notes=Tell%20me%20a%20little%20about%20your%20%22Wish%20List%22%20so%20I%20can%20refine%20this%20search%20for%20you.%20%0A%0ACall%20me%20any%20time&email=abc@abc.com
2 months ago
Hi,

This is my  post REST API



The issue is, this post call is returning 404 sometimes when i pass certain data in notes variable , i.e
Tell me a little about your "Wish List" so I can refine this search for you.

Call me any time


But when i pass data something like test in notes, it is returning proper response.
This issue is not occurring when i am running the application in local. But occurring in production environment.
So, I have added the log, to see whether it is entering the POST method, in the case of 404 response, it is not even entering the method. The log is not being logged.

Anyone has idea what would be the cause for the issue. It is behaving weirdly.

Thanks in advance.
2 months ago

Campbell Ritchie wrote:Most of the wrapper classes have their constructors deprecated, so the usage is no longer new Integer(123) but IntegervalueOf(123).
Most of the types introduced in the date time and Streams API have factory methods and private constructors, so the following usages would be impossible:- new Optional<String>("CodeRanch"), new IntStream(1, 2, 3), and new LocalDate(2021, 11, 7). In all cases the usages use the of() method:-- Optional<String>.of("CodeRanch"), IntStream.of(1, 2, 3), and LocalDate.of(2021, 11, 7). In all these cases the usages use the of() method, and I am not sure I have got the Optional example right.



But i didn't see any of the classes/interfaces mentioned above matches the Factory Method Pattern definition.
Factory Method Pattern defines an interface to instantiate an object, but lets the sub classes decide what objects need to be instantiated. Factory method pattern lets the class defer to sub classes for object instantiation.

I want to know java API classes following this definition.