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

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....

Need help setting up CSRF on spring backend with a react frontend

I was just going through the spring docs to setup csrf protection with a SPA (react) frontend and found this code here that they suggested I use, ```java @Configuration @EnableWebSecurity...

how to use login credentials for spring app in postman?

hey guys. can smb help me out? i cant use login and password auth in postman for my spring app. i have this websecurityconfig: ```java @Configuration @EnableWebSecurity public class WebSecurityConfig extends WebSecurityConfigurerAdapter {...

JWT return Dto. Login and Register REST Endpoints

```java @PostMapping("/register") public AuthenticationResponseDto register(@RequestBody Command command) { return authenticationService.register(command); }...

Spring MVC

I am Trying To Upload image and save it but i got error Code : ```@PostMapping("/registration") public String registration( @Valid @ModelAttribute("finderUserPojo") MovieFinderUserPojo finderUserPojo , BindingResult bindingResult , HttpSession httpSession , @RequestParam("image") MultipartFile image , Model model) { ...

DionysisT

Hi guys i am implementing a website with bcakend as rest-api with spriongboot and i have made the auth as session but i want the static files to served by apache but before send them to client to use the auth from springboot on tomcat how could i done it?

Apache Mina SSHD server

hi guys.. I built a SSH server using Apache Mina and StackOverflow. Now, I ran into the problem, that I am unable to get the String which was input as username or password... This is annoying and the documentation is pure shit. If anyone can tell me what I need to read the client input properly, please help me. CNCServer: https://pastebin.com/Ab1mkdEM Commands: https://pastebin.com/C0yzEvsG PasswordAuth: ```public class CNCPasswordAuthenticator implements PasswordAuthenticator{ ...
No description

Will Pay for Help

The highlighted part is the problem but idk how to stop it from happening ```import java.util.Scanner; import java.util.Random; ...
No description

where do config values come from?

usually in configs you have smth like this: . where you specify from where the value comes from. in this screenshot it comes from application.yaml file. but idk where it comes from in my BankAccountConfig?: ```java @Component...
No description

what the hell is model and why controller returns random string?

hey guys. can smb explain what the hell model is? bc i tried googling and its just vaguely said that model is your data. yes, i know its from MVC pattern, but it still doesnt make any sense, can smb explain what the f is going on here: ```java @GetMapping("/importBgwEod") public String importBgwEod(Model model) throws JAXBException, IOException { importService.importBgwEod(getUserId());...

Spring MVC checking user password

I am Trying to check the user is already registered or not as well as the password is correct or not but i am getting error as i mentioned down here is the both controller -> ```@GetMapping("/login") public String loginPage(Model model) { model.addAttribute("movieFinderLoginUserPojo", new MovieFinderLoginUserPojo());...