Java Community | Help. Code. Learn.

JCH

Java Community | Help. Code. Learn.

With more than 20,000 members, join one of the biggest and most active Java Communities on Discord! ☕

Join

java-help

❓︱qotw-answers

jackson json question

suppose i have json array stored inside the file in the projects variable. how can i update it properly without rewriting it?...
No description

couldnt resolve placeholder from the config

hey guys. i have this config: ```yaml bankAccounts: - iban: "LT123" cashRegId: 2...

how to use resource in resourceloader?

hey guys. i have an xml in this dir: src/main/resources/communicationTestRequestBody.xml and i dont know how to specify the dir: ```java ResourceLoader resourceLoader = new DefaultResourceLoader();...

Gradle Translation

What is the gradle equivalent of this?
mvn org.apache.maven.plugins:maven-install-plugin:3.1.2:install-file -Dfile=LocalDependency.jar
mvn install
mvn org.apache.maven.plugins:maven-install-plugin:3.1.2:install-file -Dfile=LocalDependency.jar
mvn install
...

better ways to load xml as a string?

hey guys. i want to load xml as a string. im doing it this way:
String requestBodyTemplate = new String(Files.readAllBytes(Paths.get("src/main/resources/accountStatementRequestBodyTemplate.xml")));
String requestBodyTemplate = new String(Files.readAllBytes(Paths.get("src/main/resources/accountStatementRequestBodyTemplate.xml")));
and some people on the internet told me there are better ways, but they didnt explain to me. can smb help me out? thanks...

Java Rest API

Can Anyone Explain is it really necessary to make a Rest Api while Storing the user's in the db from registering page ? And when do we actually use a Rest Api in our web application ?

Force install dependency.

I have a maven project with a dependency in the pom: ```xml <dependency> <groupId>tld.domain1</groupId>...

Update Error In Spring MVC

I am Trying to update the user But i found the 405 error like this https://sourceb.in/k8YQbPRuTj why i am getting this Please Help...

Spring JDBC

I am Getting a error like this https://sourceb.in/IQyZlhnarV when i am trying to retrive the id from the table Can Someone Help please...

onMouseClicked event doesnt do anything

<Pane onMouseClicked="#selectPath" style="-fx-border-color: red" AnchorPane.topAnchor="4" AnchorPane.rightAnchor="4" AnchorPane.bottomAnchor="4">
<JetBrainsImage pickOnBounds="true" icon="AllIcons.Expui.General.Open" />
</Pane>
<Pane onMouseClicked="#selectPath" style="-fx-border-color: red" AnchorPane.topAnchor="4" AnchorPane.rightAnchor="4" AnchorPane.bottomAnchor="4">
<JetBrainsImage pickOnBounds="true" icon="AllIcons.Expui.General.Open" />
</Pane>
...

Gradle shade not shading in one operating system, but does in another

I made a docker container meant to build all my paper plugins (minecraft server). The problem is that by somre reason, it does not shade what is otherwise being shade when I run the same command in my OS (windows) Does anyone have a clue what would be the case? I'm quite new to gradle, so that might be the cause. Here's part of the build script: ```kts shadowJar {...

Spring MVC

Whenever I Click on the
profile
profile
endpoint then my console is starting printing the image of the user in binary format that cause alot of lagging and stopping my program. Please Help. https://srcb.in/wGaSDYunV1p...

How to access authenticated user/authentication object on react frontend after logging in?

I've set up a basic authentication flow using Spring Security 6 on my backend, with React handling the frontend for login, signup, and verification pages. It's all session cookie-based, no JWT, with sessions stored in Redis. Now, I'm wondering how I can handle things on the React side once a user logs in. How do I check if a user is logged in to restrict access to certain pages? I want to redirect them to the login page if they're not logged in or restrict page access based on their roles. Any tips on how to manage this? I also want to be able to get access to the authenticated user's details like their email, username, etc unless this isn't possible without implementing a /me endpoint on the backend that fetches the user details for me....

Implementing Desmos Function into Java

I've got a function in desmos and want to convert it into java, but I can't figure out how I would put this:
No description

I cant figure out how to rename a file.

in order to delete from a file I first need to write everything that I don't want to delete into another file and then rename the the new file to the name of the old file. Then I would delete the old file. This is represented in the getDate() method. I am noticing that the new file (temp.txt) refuses to be renamed to the old file (savedata.txt). What should I do

Java Spring Help regarding @AutoWired

why doesnt this work there is a bean of Parrot.class but why doesnt AutoWired inject it to parrot identifier i read the documentation of AutoWired and it should do this according to it....
No description

Spring JDBC

I have added a image into My Database! But Now I don't know how to retrieve it from database and show it on my frontend. Can Anyone Help ?

java

help with implementing a menu

Trying to implement CSRF protection with Spring Security and React frontend

I'm trying to get CSRF protection to work using spring security but I keep getting a 403 forbidden error when trying to make a post request to a csrf protected endpoint using postman. I followed the docs to the letter - this one to be specific with the only change being I replaced this line .addFilterAfter(new CsrfCookieFilter(), BasicAuthenticationFilter.class); with .addFilterAfter(new CsrfCookieFilter(), customUsernamePasswordAuthFilter.getClass()) as I have implemented a custom UsernamePasswordAuthenticationFilter to work with my frontend SPA built using react. On postman, there are two cookies present - SESSION and XSRF-TOKEN and I also include a X-XSRF-TOKEN header while making the post request and still get a forbidden error. I'm not currently sending any requests from the SPA directly. Just using postman for now....