Win a copy of Microservices Testing (Live Project) this week in the Spring forum!

Matloob Hussain

Ranch Hand
+ Follow
since May 13, 2011
Matloob likes ...
MySQL Database Java
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 Matloob Hussain

Hi Winston,

Thank you for your reply.

First One: I used indexOf method of String as:

please let know. Is it correct?

Second One: I used break to stop the for loop. If any character entered by user as an input.

let suppose , I have array {"tea", "bat", "eat"} and user input :'a' , 'e', 't'

my first loop pick the first element which is "tea" and then second loop runs and check all three characters which this string contains.
When it picks second element which is "bat" and first character 'b' does exists in "bat" string then break keyword works and stop the second loop and then check for third element which it contains three character so output will be "tea" and "ate".

Please advise, thanks...

I need to submit this code today. Please give me all the information which you can?

Thanks once again.
10 years ago
Hi Winston,

Thanks for your reply.

As you advised to write separate function for each thing and also java.lang.String instead of ""+input[y]. Here is the updated code, Please let me know, if is it correct?

One thing more, which one shall I use java.util.Set or binary search. I am allowed to change the algorithm of my code. The task is to find all possible words from dictionary data of given characters. If i use binarysearch() method and finds all possible word which contains all these given characters.

Thanks in advance

10 years ago

I have dictionary data in the form of array of string. This application get characters input from user and print all the possible words from dictionary data based on user input.

I wrote this code, which works fine but is there any other way, I can impove the my code when using large amount of data. For example, Shall I use Collections to store the dictionary data and use binarysearch method or any other method to to acheive it.

In this example I just assumed, I have dictionary data of three characters and user input is also characters.


Kind regards,
10 years ago
I studied these principles one by one and used in examples seperately. Is there any book or other source in which all these concepts used in one application as an example?
10 years ago
Thank you for reply.
Yes, I mean all that.
My question is when and where we should use principles of OOP? --> abstraction, ploymorphism, inheritance and encapsulation
I know how to implement these as code wise but when we use all these features then how do we put all these together practically? In which sequence we should use these one?
10 years ago

I have few interviews for java developer. They gave me the
question, to write the java application by using java principles.
My interest is; How to start to develope a java application by using OOP principles?
Is there any java book or any other source with examples of how to start development of java application practically?


Kind regards,
10 years ago
Thank you for your reply, Now it working........ but another issue?
I retrieved data from table of mysql database and stored in List named data using servlet. I used request.setAttribute("data" , data) to set request attributes and dispatched using folloing code, which works fines. I can access the data in userLogged.jsp page.

Now on userLogged.jsp page, I called another servlet named which will add one more record in table of mysql database (which works perfect) but in this servlet I tried to access this data of type List using request.getAttribute("data") ---> this does not work, it gives me "An Exception has occurred! java.lang.NullPointerExceptio"

But if I do it using session.setAttribute("data" , data) and session.getAttribute("data") ----> it works fine , I can retrieve data of List and use it in this servlet. Could you please explain. And one thing more, shall I use session or request to transfer data from one servlet to another servlet.

10 years ago
This is my login servlet used to verify login details:

This is ViewAgentsServlet used to get data from table of mysql database and stored in List named agentList. This is working fine, I check in console, agentList is showing the data.

This is the div which is added to userLogged.jsp. When I enter userID and password to verify login detail and then session is created and redirected to userLogged.jsp. At this stage, it could not get any data of List. An method called on this List type in this jsp page cause the exception. This is I am thinking....

10 years ago
I created a servlet named which is used to access table from mysql database and store table information in a list and then this list is passed to jsp (named adminViewAgents.jsp) where I want to display.
I have another servlet which is called at the start to varify the user name and password then forward to login panel which is a jsp page(userLogged.jsp). Once user logged and reached to userLogged.jsp where the user has option to call servlet.

but it give me following error

HTTP Status 500 -


type Exception report


description The server encountered an internal error () that prevented it from fulfilling this request.


org.apache.jasper.JasperException: An exception occurred processing JSP page /adminViewAgents.jsp at line 16

13: </tr>
14: <%Iterator itr;%>
15: <% List mydata= (List)request.getAttribute("data");%>
16: <%for (itr=mydata.iterator(); itr.hasNext(); )
17: {}
18: %>
19: </table>


Thanks for your help in advance

10 years ago

I started learning Servlets and JSP technologies. What are the differences between paramameter and attributes and also If anyone could explain the different types of scopes (page scope, session scope, application scope etc).
My code does not work when I use class without any package. When I use foo package then it works by finding Counter class in directory "WEB-INF/classes/foo/" but when I don't use foo package then I should find Counter class from directory "WEB_INF/classes" but it does not work and one thing more, do we need to use import attribute in page directive when we are not using any package. all java classes in classes directory. class

JSP code

I passed my OCJP 6 with 78% marks, I used Kathy Sierra's book for prepation. which was really very handy. Now I am looking for certification ( Java Platform, Enterprise Edition 6 JavaServer Pages and Servlet Developer Certified Expert Exam ). Is there anyone know the usefull resources or book for the preparation for this exam. Please advise me.

Thank you.


Can we use floating-point literal for hexadecimals numbers. here is the example:

x1: 4095
x2: 4095
x3: 65535.0
x4: 65535.0

It is not considering F or D as a suffix. Is there any other way it can use F or D as suffix or it is not possible(which is assume).