Click here to Skip to main content
15,885,915 members
Home / Discussions / Java
   

Java

 
AnswerRe: Has anyone solved Java exercises in PDF? Pin
Richard MacCutchan29-Apr-21 21:31
mveRichard MacCutchan29-Apr-21 21:31 
GeneralRe: Has anyone solved Java exercises in PDF? Pin
Gonzalo Cotanda Gisbert30-Apr-21 4:51
Gonzalo Cotanda Gisbert30-Apr-21 4:51 
QuestionHow to apply search functionality on jtable if we are fetching the data from DB? Pin
Rocking Kapil16-Apr-21 18:40
Rocking Kapil16-Apr-21 18:40 
QuestionRe: How to apply search functionality on jtable if we are fetching the data from DB? Pin
Richard MacCutchan16-Apr-21 21:51
mveRichard MacCutchan16-Apr-21 21:51 
QuestionJdbc Pin
Bhakti mishra28-Mar-21 23:51
Bhakti mishra28-Mar-21 23:51 
AnswerRe: Jdbc Pin
jschell9-Apr-21 15:18
jschell9-Apr-21 15:18 
AnswerRe: Jdbc Pin
SeanChupas29-Apr-21 6:18
SeanChupas29-Apr-21 6:18 
QuestionUSER AND ADMIN EXCHANGE IN JAVA SESSION WITH STRUTS1 Pin
waga197923-Mar-21 23:26
waga197923-Mar-21 23:26 
Hi, I ask for help from anyone who can give it to me regarding a problem that I have not been able to solve for days.
I am creating a website with JSP + STRUTS1 technology that relies on a Tomcat 9.0.33 server and in the middle there is an Apache web server that acts as a proxy.
As a programming editor I use Eclipse. IT IS SPECIFIC THAT SO GIVING THAT THE ERROR I HAVE WHEN I START THE PROJECT WITHIN ECLIPSE IT DOES NOT MATTER THAT THERE IS APACHE IN THE MIDDLE BECAUSE ECLIPSE LAUNCHES ME LOCALHOST: 8080 / SITE NAME SO IT DOES NOT GO FROM APACHE UNTIL I TEST IN ECLIPSE
The problem is this:
I login from a home.jsp page through a form whose submit has been overwritten in jquery which makes an ajax call which calls a Login action of struts, in that action I put the user in session. At the end the call the ajax does window.location.replace (urlSite + "/"), that is relaunch the home of the site and I am still in home.jsp which however no longer shows the login form but a welcome note as it detects in session the user.


I state one thing to understand: a user can also be an admin and vice versa. In this site, if a user decides to become a recipe inserter, then a record is also inserted in the admin table with some user data and therefore we will have both a user and an admin connected to each other by a user_idUser field in the Admin table and admin_idAdmin in the table User. While browsing the site, if you enter some areas, the actions will remove the user in session to put his corresponding admin in session and when you exit these areas, the admin will remove himself from the session to put his corresponding user in session. These in-session objects are the UserBean classes (which contains an idAdmin property indicating its corresponding record in the Admin table) and AdminBean (which contains a UserBean object representing its corresponding user)

So far so good but the problem is a link always nalla home.jsp.


If I click on this link an action is called that removes the user from the session and puts me in session an admin corresponding to the user I have removed. The link is this:
<html: link action = "$ {urlBase} / Recipe? logoutUser = true" styleClass = "itemSubmenu"> <bean: message key = "organizeRecipe" /> </ html: link>
the logoutUser = true "attribute makes it clear to the Recipe action that it must remove the user from the session and put his admin in session.

Even so far so good because in the Recipe action in debug in Eclipse I see that it removes the userBean and inserts an adminBean.

Recipe action makes a forward on recipe.jsp and in this page I see that it detects in session an admin and not a user which is what I expect so ok.

Now the link is this
<html: link action = "$ {urlBase} / Recipe" styleClass = "itemSubmenu"> <bean: message key = "organizeRecipe" /> </ html: link>
which is right, only the logoutUser = true attribute is missing, because in the jsp there is a control that says that if there is a user in session then the link has the form with that attribute, while if in session there is an admin there is no attribute.

THE PROBLEM IS NOW: if I click on the link without attribute I expect that in the Recipe action now I see that the userBean in session is null and that there is instead an adminBean in session, INSTEAD THE CONTRARY DOES NOT HAPPEN, USER NOT NULL AND ADMIN NULL AS IF SOMETHING HAPPENED IN THE PASSAGE FROM RECIPE.JSP. I PROMISE THAT THE ID OF THE SESSION IS ALWAYS THE SAME FROM THE BEGINNING TO THE END BOTH IN THE JSP AND IN THE ACTIONS

I have no idea why I hope someone can help me thanks

QuestionFacing Issues regarding Bean Pin
Member 1511521823-Mar-21 8:14
Member 1511521823-Mar-21 8:14 
Questionhow to do it Pin
zahidul hasan21-Mar-21 21:07
zahidul hasan21-Mar-21 21:07 
AnswerRe: how to do it Pin
Richard MacCutchan21-Mar-21 22:48
mveRichard MacCutchan21-Mar-21 22:48 
QuestionHow to update nested Array in Spring boot mongodb Pin
devTUapp15-Mar-21 7:33
devTUapp15-Mar-21 7:33 
QuestionWhat should I I learn with Java? Pin
Member 1509539610-Mar-21 3:02
Member 1509539610-Mar-21 3:02 
AnswerRe: What should I I learn with Java? Pin
NotTodayYo10-Mar-21 3:40
NotTodayYo10-Mar-21 3:40 
AnswerRe: What should I I learn with Java? Pin
Richard MacCutchan10-Mar-21 4:06
mveRichard MacCutchan10-Mar-21 4:06 
QuestionPass variable to HttpURLConnection Pin
xoduhuko10-Mar-21 2:40
xoduhuko10-Mar-21 2:40 
QuestionHow to compare two similar xml documents ignoring node text values by using XMLUnit? Pin
mr.pakapun1-Mar-21 17:32
mr.pakapun1-Mar-21 17:32 
SuggestionRe: How to compare two similar xml documents ignoring node text values by using XMLUnit? Pin
Richard MacCutchan1-Mar-21 21:22
mveRichard MacCutchan1-Mar-21 21:22 
QuestionLicense key generator Pin
keznet lisimati27-Feb-21 0:27
keznet lisimati27-Feb-21 0:27 
QuestionDefault My program does not find the file MyFriends.txt Pin
zorapulo11-Feb-21 16:25
zorapulo11-Feb-21 16:25 
AnswerRe: Default My program does not find the file MyFriends.txt Pin
Richard MacCutchan11-Feb-21 21:24
mveRichard MacCutchan11-Feb-21 21:24 
Questionhow to write result in excel using java selenium. Pin
Member 1393850211-Feb-21 2:46
Member 1393850211-Feb-21 2:46 
AnswerRe: how to write result in excel using java selenium. Pin
Richard MacCutchan11-Feb-21 3:01
mveRichard MacCutchan11-Feb-21 3:01 
Generalhow to write result in excel using java selenium. Pin
Member 1393850211-Feb-21 2:32
Member 1393850211-Feb-21 2:32 
GeneralRe: how to write result in excel using java selenium. Pin
OriginalGriff11-Feb-21 2:50
mveOriginalGriff11-Feb-21 2:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.