Harish Moolchandani

+ Follow
since Mar 12, 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 Harish Moolchandani

What is the scope of SAP today as compared to JAVA?
Is SAP professionals highly paid or JAVA professionals are equally paid as SAP?
Can I find a good SAP job after 2 years of experience in it?
I like java, but have to select SAP because there was no other option. So should I stick to it or try to switch to java.
8 years ago
So, what is the other way around?
The only other way it seem is to have <jsp:include> on all pages.

But, for admin, there will be different menu options, for consumer there will be different menu options.
So, this solved my problem.
But this is my question, what is the other way around? And how can I display different menu's for different users?
9 years ago
I want to create a master page in jsp, similar to ASP.Net.
I'm not using any framework.
I don't seem to find a good solution on internet.

What I have done till now is:
Created a master page called master.jsp
It has an attribute "redirect" which is used in <jsp:include>
So whichever page I put in redirect parameter will be called by include tag.
<jsp:include page="${redirect}></jsp:include>

But the problem is, the calling of pages should be like this

9 years ago
I've to make view and controller for registering different types of users

How to implement it using MVC pattern in java?
Currently I did it like this,

RegisterAs.tag (A tag, user selects the user type and press register button. It passes USERTYPE in the query string).
RegisterUserFormController.java (Sets the bean objects required by form, such as "Skills" bean object).
RegisterUser.jsp (The form for registration according to the selected usertype).
RegisterUserController.java (Checks the usertype, creates appropriate model and passes it to insertUser method).
DisplayMessage.jsp (Shows a message whether registration is successful or not).

Also, should I make different registration forms for different users? such as RegisterConsumer.jsp, RegisterEmployer.jsp, etc and then there will be different controllers for each of them. I didn't do it like this because each of them has almost similar functionality.

And I had EditUser functionality similar to this.
I recently decided to use custom tag files in my project instead of using <jsp:include>
But now, Location.tag(View) -> LocationServlet(Controller) -> DisplayLocations.jsp(View)

Location.tag sends the request to LocationServlet, so can I consider it as a view or the jsp page which uses this tag is a view (Example: Registration page use this tag, so it will be the view which calls the Controller?)
Same goes for Login.tag
I mean that, I can directly specify a javascript function call to a html tag inside Tag file
such as

And specify the validate function in JSP page which uses the tag, since the output of tag file is going to merge into jsp page, it will work. But I don't think its right thing to do.

Should I code it like this:


I'm still confused with the displaying of ajax content. If I use Login tag in index.jsp, I want when user clicks on submit, it will go to LoginServlet. If user is not existing in database, it will redirect it to index.jsp(since I cannot redirect it to tag) passing errorMessage in Query String. Now how will I show this message in my tag, since tag is already rendered by JSP.

Only way I see to do this is to call LoginServlet and it will then forward the errorMessage to another JSP page called ErrorPage and it will just display the errorMessage recieved. Now when the response is sent, it contains this errorMessage and ajax will reflect it to the desired location. So, I'll have to make a seperate JSP page just to display a message :shock:
(I know the concept of error pages, but they are used to display a user friendly error message if any exception occurs in our JSP. I'm using it to build an ajax response). Am I on the right track or not.
9 years ago
At first, I decided to accept login input from HTML controls and then it will send the data to the LoginServlet which will checks the database and logs in the user and redirect to its homepage view.
But now, I'm thinking to make login tag file.
But should I include a submit button inside the tag file or I should keep use it outside.
Also I have to use javascript for validating empty textboxes. So should I put javascript in tag file or not?

There's more, I will use a html tag(label or div) inside tag file for displaying errors, this will be mostly used for ajax purpose (such as "username is in use"). So I need to specify a javascript function. But where will I put this javascript function. And if I put it outside the tag file (i.e. in a jsp page), then I have to declare an attribute in the tag file, so that I can call the javascript function from within the tag file.

Although, I can simply put a call to javascript function inside a tag file without an attribute, but that doesn't seem right thing to do.

9 years ago
Ok, jimmy
You are right, I will waste my time if I try to make it perfect.
But I always try to do new things, if I won't go for new things then I cannot learn anything new from my projects.
This is my first MVC project and I learned there's much more in project designing than MVC and that's design patterns. I'm implementing the sun's suggested method of DAO pattern (the factory pattern) in this project.
I learned other things as well, such as more clear concepts of MVC. I always knew the theory but never used it in any project.

I'll follow your advice and just try to complete my project on time.
Thanks for all the help.
Well its like this,
A consumer will be a member of household.
There can be multiple consumer related to a household.
This household have one username and password.
The household user can view its consumer's details, including the projects done and locations.
While registering for household, user can add consumers there or can add after registering household.
After registration this household will be verified by admin.
Employer can provide projects and provide job related to that project, and consumer will apply for those jobs.
And there's more than this.
I've thought the project and its flow. Its just I cannot implement it in a class design.

Now the problem is, if household user clicks on consumer details it should also show its employment history and work done in the past. So I take a class named project and I can insert a Project object in consumer.
But any user can see any project and it should show employees working on that project with their roles and location.
So, isn't its confusing, project has consumers, and consumer has project.
Also Employer has projects.
If I has to show which employee is working under particular employer, I've to choose a project first from the employer and from that project I will select employee list.

Sorry if I sound stupid, but I've to do everything by myself alone and no one to guide, and there's so much less time to make it.
It's like this, a consumer can choose to apply for a job provided by employer.
After he/she got the job, its information is stored in a seperate table.

Id, JobId, ConsumerId, EmployedFrom, EmployedTo, TotalAttendence, PreviousAttendence.

I named this table as Employee. A consumer can find out its previous or current jobs through this table.
But the class Employee will inherit Consumer. So, there will be a problem, since according to class Employee, one consumer can be employee of one job. But this is not what I want.
So I renamed the table to Employment, and took a class called Employment which will have all these details, and the employee class will have a List<Employment> named employmentHistory, through which I can track what jobs this consumer had in past.
But the naming of the class and relationships doesn't feel right.
I'm doing a project first time using MVC-DAO. And this time I want to make proper bean files and classes. But its so much confusing.

There will be 5 users in the system.
consumer, employer, manager, admin, public reviewer

Adult members of a household can become consumers.
The consumer can opt for various schemes and employment is one of them.
We have only taken one scheme currently which is Employment, but more will be added in future like health and poverty alleviation schemes.

So these are the classes I've considered so far.

User - Abstract Class
Person - Interface (Had to take as an interface, some classes need both user and person features, so have to make one of them as interface).
Household Is An User - (Household extends User)
Consumer Is A Person - (Consumer implements Person)
Household has many Consumers
NonConsumer Is An User and A Person - (The consumer will not be a user, a household will be. But the other persons such as Admin, manager, employer can be users. So took another class)

This is more confusing -
Employee Is A Consumer
Employer Is A NonConsumer
Employer Has Projects - (Employer will provide projects)
Project Has Jobs - (Job requirements based on Projects)
Job Has Employees - (Need to see who worked for this job)
Employee Has Employments - (The Employee has Employment History, so that he/she can view the jobs they worked at)
Empoyment Has A Job - (even more Confused)
Job has A Project - (Job can reference back to which project it belongs).

Please tell me what's wrong going here, I have a feeling that this model is not correct. Any classes to add/remove. Please help me correct it.
Yes, I kept your data consistency thing in mind.
I'm using a DAO for selecting types, These types will be selected from database.
The DAO will ensure that selected type will be consistent and will have proper parent child relationship. And still working on that

And changed the name to addChild().

9 years ago
Hello Rob, thanks for reply. I've decided to code it like this:

But will it still be a javaBean, because javabean should not has a getter which accepts an argument.
Any other suggestions/advice?
9 years ago
Hello, I'm beginner in MVC concepts and need help in designing java beans.
I've a table names types and it has a foreign key (parentType) pointing to itself.

So what fields should I take for java bean Types.
long typeId;
String name;
String description;
long parentTypeId;


long typeId;
String name;
String description;
Type parentTypeId;


long typeId;
String name;
String description;
Type parentTypeId;
Type[] childTypes;

any other recommendation will be helpful.

Please Help
9 years ago