Raman Ghai

Ranch Hand
+ Follow
since Jan 01, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Raman Ghai

Hi there ,
I have a Struts2 Hello World application in Eclipse JUNO for EE developers which is giving this weird exception when I try to deploy it on Tomcat7.
Here is the exception :


web/WEB-INF/web.xml


web/WEB-INF/struts.xml


1. If I remove the entry from the web.xml file , the application gets deployed but does not open the HelloWorld.jsp page.
2. I read somewhere to make the value of devMode to false but even it didn't help.
3. I tried using org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter as filter class but even it did not help.

Please help .
4 years ago

Jeff Verdegan wrote:You might see if NB offers something similar.


Netbeans writes a logger statement by default. May be this is the best method to read exceptions so that the end user doesn't get to know that some problems even occurred.
Thanks everyone for your invaluable comments.
5 years ago
Hi there ,
Whenever I write the following kind of code, there is a warning in Netbeans that it is not recommended.


Why netbeans suggests that Throwable.printStackTrace() should be removed. ?
Any suggestions will be appreciated..
5 years ago

Campbell Ritchie wrote:Thank you.


You are welcome
5 years ago

Campbell Ritchie wrote:Are those Paths Path and Files classes from NIO2?


yes ..
5 years ago

Stephan van Hulst wrote:Perhaps you can take a look at what the documentation says about the possible parameters for Files.newBufferedWriter().


Yeah , I had to include some parameters(StandardOpenOptions) alongwith path and charset and it worked ..thanks
5 years ago
I have the following method to write data to a file .

However , this overwrites the file everytime . I want to append the file . I guess there is no method in BufferedWriter class to append the data to the file . Any ideas about that ?
5 years ago

Richard Tookey wrote:
Surely that can't be the correct approach since you are unlikely to have access to the 'prices' array when you read back the data. You need to write this length to the output file so it can be read back and used to create the correct length of array !



So you want to say that everytime someone writes some data to the file ,the length of the data is also written/updated to the file (different file or same file ?) ? what can be the other approach to know the length of data in such a file before reading the file ?
5 years ago

Richard Tookey wrote:You get the exception because you try to read more data than you have written. You have two obvious choices -
1) Catch the exception and recognize that when you get an EOF exception that you have read all the data.
2) Write the number of data items to be written before you actually write them. You can then read read this number back to know how many data items to read.

I consider the first approach to be a hack and would recommend the second approach.




Yeah , actually the while loop created the exception . I removed it and using a counter to read it prices.length times and it worked..Thanks for replying.
5 years ago
Here is a code that writes data to file and reads using DataInputStream and DataOutputStream


Exception


I am not able to understand how to get rid of this exception ?
5 years ago

Paul Clapham wrote:Well, there's a String constructor which accepts a char array, isn't there?


Yes, there is


//Calls

thanks
5 years ago

You twice made the assumption that a char[] is the same thing as a String. Its not:


Just to confirm

Output : false
Well , I need to find some other way out. Btw thanks for replying
5 years ago
Hi there ,
I have created a program that stores and authenticates a user using a file .
Here is the code :


The passwords don't match even if I enter same passwords . How to solve this problem ?
Whenever a new user enters , the data overwrites the previous contents of the file , how to append ?
Can I use regex to compare here ? Any ideas will be appreciated ..thanks
5 years ago
@Richard Tookey yeah , it could be used to subtract characters from a particular range , that's what I thought too.
@Campbell Ritchie thanks for the suggestion
5 years ago
Both of these seem the same to me . then , What is the use of && in regular expressions ?
Check the following test cases :

Another one :
5 years ago