Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

Mumtaz Khan

Ranch Hand
+ Follow
since Feb 21, 2008
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 Mumtaz Khan

I am developing a web application in struts2 where I need to display image on jsp pages. Many questions have been asked in different forums but I am not be to get solution for my problem.
My application receives images in form of file through mobile application which is being developed in Titanium. I am saving the file as : which saves it as long blob. format of images png.
I am trying to retrieve it in my action class and setting it to inputStream. Here is the code for this: Entry of struts.xml file is : In jsp I am calling the action as:I am able to retrieve the image from database and save in /images under webcontent but not able to display using stream. It says: The image ",......" cannot be displayed because it contains error. I am not getting any exception in log files. In stdout I am getting this: I am not able to understand why image is not being able to displayed? Is it because of length?If so how can I get contentLength for inputStream?
Please help.

Thanks in advance!
11 years ago

I have a struts2 based web application and I am using json-default to return json result type as response from my action class. I am able to call this action from browser but not from another application, which is a mobile based application that is developed in javascript. Here is my javascript code to call the action in struts web application:
Entry in struts.xml is:

Do I need an interceptor in struts application to receive request from mobile application?What is the other way to call struts 2.0 application from a mobile application to receive JSON response? Looking from some help.Thanks in advance.

11 years ago

How can I make a call to struts 2.0 based webapplication from a mobile application as client ? I know this can be done with JSON, but I am a newbie to both struts and JSON. Can anyone help me.
11 years ago

I am trying to implement JAAS as an authentication and authorization service for my web application. I am using tomcat 6.0.20 server and mysql as database. I have read many articles on how to implement JAAS, infact have implemented it in a stand alone application where I am passing "" parameter as argument pointing to the jaas.config file.
For my web application , following this link, I added JAAS realm in server.xml but instead of providing authentication for specific application it is asking for authentication for Tomcat manager application when I am trying to run the application. How can I avoid this? Also which file should I add this$CATALINA_HOME/conf/jaas.config ?

The authentication should happen when I am submitting username and password on my login page.
Appreciate your help!!

12 years ago
Thanks Henry, it worked
12 years ago
My bad, didn't explain the whole problem. I have a message which I am encrypting with k1 and then encrypting k1 with a symmetric key k2 which is shared with another program. After encryption both encrypted message and encrypted key is being passed to another program which has access to k2. so after decrypting "encrypted key" with k2, I am getting byte[] but now how can I get the original message which has been encrypted using k1? To generate the key I am using "blowfish" algorithm. Now can you help me to recover Key k1 from byte[] object?
Ulf: yes I am trying to encrypt encryption key using a symmetric key.
12 years ago
I am very new to java security. I am trying some encryption and decryption.
I have two key, k1 and k2. I am encrypting k1 using k2 which generates cipher-text. Before encrypting k1,I got the byte[] for k1 using k1.getEncoded(). I then decrypt cipher-text by using k2 which returns me byte[] object. How can I get back the original key k1? Here is the code
getNewKey() is another method thats generates a key. I tried to use unwrap method, but since I am not wrapping the key, its giving exception. I am not able to generate the original key k1 back from byte[] object decryptedTextkey .
Could anyone please tell me how can I get k1 back?
12 years ago
Yeah it was a bit complicated . So I changed my approach instead of using another class, I am using an inner class that extends JPanel and it works. The code posted above was not working even with invalidate and repaint may be because I was not calling super.paintComponent(g); .I think this needs to be called for repainting graphics object.
12 years ago

I am very new to swing and java awt. I am trying an application where I have 2 panels in main container. First panel (p1)contains some data and a button , upon click of button, Second panel (p2) has to draw a graph based on the content of first panel.
To draw the graph I am creating another class called secondPanel and passing p2 in the constructor, to get the graphics object of p2 to draw the graph.
The problem I am getting is when I change the data and redo the graph it retains the old graph. As I understand it is because of the graphics object that I am getting from p2.
before passing object p2 to the constructor of SecondPanel, I am calling removeAll() and validate() on p2, however my graphics object is not recreated.
Really appreciate if someone can help me here. Here is the code snippet of SecondPanel.

In the main container here is my code of reloading p2
How can I reload the graphics. while using super.paintComponent(g), I am getting null pointer exception and I don't know whether graphics object obtained by super will fit my requirement.
Thanks in advance!!!.

12 years ago
what exactly you are not understanding?
you can break the format string as 45 + %2$b + %3$+04d .The first part is simple, its 45. The second part is about boolean conversion character that returns false if the argument arg is null. If arg is a boolean or Boolean, then the result is the string returned by String.valueOf(). Otherwise, the result is "true" for any value. So second part will become true. The third part is checking about flag and width, here the flag is (+), which will always be included in result. Value of width flag is 4, so minimum character should be 4, which makes the third part +321. Adding these three part, result will be 45true+321.
I hope this explanation helps you.

Here is another code snippet, Output of running this code is
s size 2
s1 s1 size 3
If you change s and s1 to Integer[], it will give java.lang.ArrayStoreException which is beacause runtime type of the specified array is not a supertype of the runtime type of every element in this list.

So, Isn't the implementation violating the contract , i.e " If two objects are equal by equals method, their hashCode must be same "?
Back to the original question, when the question statement is like "fullfill the equals() and hashCode() contract", should such kind of implementation that violates the contract be chosen? As this question is from K&B, it has confused me about the contract and implementation.

You are still not using code tags, you are referring to some line numbers but there is no line number in your code. please use code tags, it makes code readable.
13 years ago