James Haville

+ Follow
since Jul 19, 2010
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 James Haville

I managed to do it.

Here is the solution if anyone has a similar problem in the future:

and the javascript

I can get the id doing this...

And this in the servlet...

However when I introduce a hidden field i.e....

I have the problem where it only recognises the last activity id.

David Newton wrote:I'm not entirely clear what you want to do, but if you mean you want to send the appropriate activity id on a submit you could just use JavaScript to set a hidden field, just use the activity id as an argument in an on click/whatever call. Although I'd say if you're not really doing anything other than that I'd probably just use a link rather than a form.

There may be several activity updates on the page each with different IDs. The user can click 'view comments' on each one. I want to be able to get the appropriate ID on the activity they have selected in my servlet by getting the parameter. At the moment if I try to get the ID it just gives me the last activity ID and not the specific one they have selected to view the comments on.

I think I understand what you are saying with the JavaScript. But I am not too familiar with it so could you clarify the process for me or point me to a resource(s) that will do this. What do you mean when you say 'use JavaScript to set a hidden field'?


Need some help on the following.

I have a project overview jsp which displays project activity and a view comments button for each activity belonging to the project:

What I want to do is extract the activity id according to which view comments button the user has pressed. I can do this with checkboxes by getting an array of parameter values but with submit buttons it just seems to take the most recent activity id. I've played around with hidden fields etc but cant get it to work.

Thanks in advance,



Not sure which section this should be in...

I've been working on a web-based project management system and was wondering how you may do the following:

1) When a user has a new message/comment on activity relating to them I want it to appear on their notifications
2) I want to display the number of notifications they have

So I will have to check the database for messages or comments. But how can I work out if these have not been accessed by the user and therefore whether to include them in the new notifications? Would I have a boolean value checking this somewhere(in a servlet?) which is returned from a database method (check number of times accessed...if zero then show in notifications). Maybe I would have a column in the database which has a value true or false as to whether its been accessed or not which is changed to true if it has been.

Does anyone have any suggestions?


11 years ago
Yep all done. Thanks for your help...

My new code:
11 years ago

I'm creating a project management website and have come across a problem. I can obtain the desired result using a scriptlet in a jsp but I would like to write the code in the servlet(controller). I have an arraylist of projectbeans of which I want to display all the information of when a client clicks on the projects button - i.e. - they will get the project id, date, and name of all the projects they are involved in.

Heres my code for the scriptlet in projects.jsp that works:

However I would like to write it in my projectsServlet and have some el scripting or jsp tags to display the information in my jsps

i.e. ${projectDetails} or jsp:useBean "projectDetails" etc etc

I can do it for one bean in the arraylist but I can not work out how to do it when there is more than one...

here is my lame attempt

and then I was thinking about displaying the project details based on the size of the arraylist but I still come back to my original problem...

In summary how do I display data from more than one bean in an arraylist of beans on my jsp page using scripting or jsp tags? I fear this is very simple but it has stumped me.

Thanks James
11 years ago
Thanks for the comments. This is my first attempt at a web application so it is all new to me but trying to learn as much as possible. I have a few further questions if you wouldn't mind.

I have my page layout sorted with header and footer jspfs for each and am able to log a user if I insert them into my database so I want to implement a create user function next.

1) From some research one of the ways to implement this would be to create a controller servlet which handles requests from the client. Would I have two methods in this servlet doGet(...) and doPost(...) which handle incoming requests according to the userPath (i.e. - request.getServletPath();) and then call methods based on what the request is and then redirect the user to the correct page? Is this an acceptable way to do it? Any other comments on this would also be welcome baring in mind I would like to avoid frameworks for the moment.

2) With the create user method itself what would be the best way of implementing it...(may be a question for another part of the forum)

that would be in my UserDao...if someone could clarify the process from the client request to create a user it would help me out as im getting a little confused as to how the information is passed end to end mainly the Beans part.

Please bear with me I have been learning Java for less than a year and did no programming prior to that. Having said that this forum is one of the best resources I have come across.

Thanks again.
11 years ago

Bear Bibeault wrote:What appears in the URL bar of the browser? What does a View Source show? Any errors in the logs?

I simply forgot to include an import

Thank you for the help.
11 years ago

I am implementing a simple login example and having some difficulty redirecting to the success page if the username and password match with those in my database.
When I press submit I get a blank page. Would appreciate any thoughts.

My code:






UserBean.java and ConnectionManager.java are also in the ExamplePackage

Thanks in advance! James
11 years ago