|
To get your proposed solution to work, you're on the right track by assuming you need to do all creation/zipping on the server side. Instead of having the jsp generate the excel files, have it done in a Servlet on your server side instead, based on parameters from the JSP page.
You can then create the Excel files (likely by creating CSV files and renaming them, or using a third party library, such as JExcel (http://jexcelapi.sourceforge.net/[^]) and return the resulting .zip to the browser for download.
Cheers!
|
|
|
|
|
Hi,
I have an ant build script as shown below.
<target name="runscript" depends="compile">
<echo file="run.sh" append="false">java -cp ${mclib}/mundocore.jar:bin Chat</echo>
<chmod file="run.sh" perm="+x"/>
<echo file="run.bat" append="false">java -cp ${mclib}/mundocore.jar;bin Chat</echo>
</target>
The build script portion produces a batch file named run.bat, which simply executes a java compiler command.
java -cp C:\mundocore-1.0.0-RC1\lib\se/mundocore.jar;bin Chat
I want to send some commandline arguments with the run.bat script.e.g in command prompt
run.bat hello
How can i change the the ant build script to generate a batch file that can accept arbitrary number of command line arguments.
Thanks in advance...
|
|
|
|
|
|
Hello
I want code to java application that simulates a simple registration systems
*Main Screen
1.Insert a new data
2.Update data
3.Delete data
4.Print all Information
5.Exit
Total number of students :4
Number of student in CIS :3
Number of student in MIS : 1
*Insert Screen
Enter ID:
Enter GPA(double):
Enter Name:
Enter Major:
*Update Screen
Update ID:
Update GPA
Update Name
Update Major
*Delete Screen
Enter ID:
Note:
1.In the(Update and delete) operation, if the user enters a not-exist ID, your application must tell the user that ID is not-exist and return to main screen.
2.In each one of(Insert and Update)operation, your program must check that there are No two students have the same ID.
3.After each one of (Insert, Update and Delete) operation, tell the user what happens(i.e. "A new record is inserted","One record is update", "one record is delete","It is Not allowed to duplicate ID","This ID is Not exist")
4.In each one of (insert and update) operation your program must check that the value of inserted GPA is between 0 and 4, and if it is Not the program must ask the user to repeat the insertion of GPA
5.After finishing any one of (insert ,update and delete) operation ,the program must return to main screen
|
|
|
|
|
See points 2 and 11 in the forum guidelines... Read the other ones as well, I think you might need it.
|
|
|
|
|
This question is far too large to be answered in a forum like this, and we do not provide custom made solutions to order. In the meantime I suggest you spend as much time as possible working through these tutorials[^] in order to develop the knowledge and skills you need to succeed in this task.
The best things in life are not things.
|
|
|
|
|
What question?
|
|
|
|
|
scottgp wrote: What question
Mohammed Kherfan wrote: <layer>I want code to
The best things in life are not things.
|
|
|
|
|
|
Hi guys,
The aim of this code is to find a file by giving starting folder. The problem is, when I use "C:\\" directory it doesn't work, even I tried "C:" and "C" if it was the problem. I think the problem is related to some Access restriction. If I changed the starting folder, lets say, to "C:\\someFolder" it will work perfectly.
How can I make the code work so that it will start searching from C drive .. Help me Thank you
package ex4;
import java.io.*;
public class FileSearchRecursive {
public static void main(String[] args) {
FileSearchRecursive x=new FileSearchRecursive();
if(!(x.searchForFile("C:\\","try.txt")))
if(!(x.searchForFile("C:\\someFolder","try.txt")))
System.out.println("File not found");
}
boolean searchForFile(String startDir,String fileName)
{
File file1=new File(startDir);
if(file1.exists())
{
File[] list=file1.listFiles();
for(File x: list)
{
if(x.isFile())
{
if(x.getName().equals(fileName))
{
System.out.println("I got the file "+x.getName()+" in "+x.getAbsolutePath());
return true;
}
}
else if(x.isDirectory())
{
if(searchForFile(x.getAbsolutePath(),fileName))
return true;
}
}
}
return false;
}
}
|
|
|
|
|
And what does "doesn't work" mean exactly?
Does it throw an exception?
Or it just doesn't find the file?
|
|
|
|
|
It throws a NullPointerException I think it is because , the application may not have an access on hard drives, but it works if I search in folders which are located in those drives. Can you try it please?
|
|
|
|
|
...you know, you need to mask the double-slash ? it's not interpreted right otherwise. the Backslash is in Java a sign for masking and special String-values like the tab "\t". To set a "\" you always need to use 2 "\\".
It's a good solution to set up a String and use this as a argument for the following commands:
FileSearchRecursive x=new FileSearchRecursive();
String strSearchFolder = "C:\\\\someFolder";
String strSearchFile = "try.txt"´;
System.out.println("Searching in folder:\t" + strSearchFolder + " for file:\t" + strSearchFile);
if(false == (x.searchForFile(strSearchFolder,strSearchFile ))){
System.out.println("File not found");
}
regards
Torsten
I never finish anyth...
|
|
|
|
|
TorstenH. wrote: ...you know, you need to mask the double-slash ?
And do you know that the OP code doesn't need to do that correct?
The code has "C:\\" which is exactly what it should have to access the C drive root.
TorstenH. wrote: String strSearchFolder = "C:\\\\someFolder";
Which resolves to "C:\\someFolder" which although it will work on windows is not any better or more correct than "C:\someFolder".
|
|
|
|
|
CoderForEver wrote: It throws a NullPointerException
The stack trace tells you where. So which line is it?
CoderForEver wrote: the application may not have an access on hard
Application? You are running exactly the code you posted from a console window correct?
Thus the only way it wouldn't have access is if you you, the user, doesn't have permission to access the C drive root. And if that was the case then you should see an exception that indicates exactly that - a permission problem.
|
|
|
|
|
Judging by your comments and code extract I would suggest the following line be changed as indicated:
if(!(x.searchForFile("C:\\someFolder","try.txt")))
if(!(x.searchForFile("C:\\someFolder\\","try.txt")))
The best things in life are not things.
|
|
|
|
|
This would show the original problem if C:\\someFolder was empty.
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
Have a bit more patience with newbies. Of course some of them act dumb -- they're often *students*, for heaven's sake. -- (Terry Pratchett, alt.fan.pratchett)
|
|
|
|
|
Exactly how I found the problem.
The best things in life are not things.
|
|
|
|
|
Interesting. When I run it on an empty directory, I get a zero-length array.
Also, it doesn't make any difference if I put "C:\\someFolder" or "C:\\someFolder\\". It behaves the same in both cases.
I only get null back if there is some kind of problem (e.g. Access denied).
|
|
|
|
|
I'll try it again sometime and check the results more closely.
The best things in life are not things.
|
|
|
|
|
Come on guys. My question is how can I find a file in "C", not in "C:\someFolder"? ... on the latter case it works easily. If you have time try to run my code, it really works. But try to make the searching folder "C:\" not "C:\someFolder". Then it will through an exception. Though thank you for your help
|
|
|
|
|
Consider these lines:
File[] list=file1.listFiles();
for(File x: list)
if file1.listfiles() does not return any items then list will be null and the runtime will throw an exception. Took me less than 5 minutes to find it with the debugger.
Lesson: Check return values and statuses, and catch exceptions: there is no alternative.
The best things in life are not things.
|
|
|
|
|
Hi,
some comments:
1.
you should implement error handling in your code; have a try-catch and log the exception.
2.
when an exception occurs, it gives the number of the offending line; that is where the problem shows itself, the actual cause may be somewhat sooner.
3.
when the exception occurs in a method call, check the documentation for that method to see what it has to say about the specific exception. That should tell you exactly what is wrong.
4.
Your searchForFile() method is a bit silly, it tells whether a file exists, but when it does, it does not tell you where it is. A better definition of it would return the path to the first occurence it finds as a string.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
What is the result of running the following? If it is exception then post the entire stack trace.
File file1=new File("C:\\");
System.out.println("exists=" + file1.exists());
|
|
|
|
|
This works for me.
As someone else has pointed out, file1.listFiles() may return null so you need to allow for that.
|
|
|
|