|
In the above JSP, result is defined as a List. A List is not an array. Even if it was an array, your code wouldn't work the way you seem to expect. Consider the following:
String[] myArray = { "a", "b", "c" };
System.out.println("myArray = " + myArray);
If you know about arrays, you will know that this does not show you the contents of myArray. Try it and see what it does.
I recommend that you read up about arrays and collections.
|
|
|
|
|
I need code for encrypt a any file using .net and decrypt it using java
please any send sample code
Thanks in advance
|
|
|
|
|
Do you have a particular encryption algorithm in mind or is it just a general question? When you say .NET do you mean C#, VB, or do you not care which language? Do you want to roll your own encryption solution or use some sort of framework or toolkit (PGP or similar). Is the file stored on disk in encrypted format for asynchronous access or exchanged over a network synchronously?
As long as you use the same encryption algorithm at both ends (Java and .NET) there is no problem with doing this at all. There are plenty of tutorials on the interweb google thing that show you how to do this for just about every technology under the sun.
|
|
|
|
|
thank Q for replay
i tried to implement a application using AES algorithm, but i did not successed. In .net i am using vb.net
please send me a any sample code to encrypt a file using .net and decrypt it using java
Thank Q
|
|
|
|
|
|
Does such a thing exist in Java? For example, I can always do something like:
AJSDate startDate = new AJSDate("20090811"); but I would rather have it as:
AJSDate startDate = "20090811";
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
No, you cannot do this in Java. It was a deliberate choice by Gosling et al. as one of their original design aims for the language was simplicity and transparency: you should always know what code does simply by looking at it, with no "hidden" effects. ("Simplicity" and Java, oh how the world has changed.)
What you can do is set up a static factory method, something like:
AJSDate startDate = AJSDate.valueOf("200090811")
That's probably a better solution for dates if you're concerned about time zones because it allows you to overload the factory method to specify a time zone as well, which you can't easily do with operator overloading.
|
|
|
|
|
i am making a project in java awt and backend as ms -access.
my project is online quiz
i want that the java should retrieve random questions ten out of 50 question from ms access database table without repetation of question in one login .
|
|
|
|
|
You could give a sequence number(1-50) to each of the questions in you access db and then do something like this every time you select a question (Generate a question number)
Random rnd = new Random();
int questionnum = rnd.nextInt(50) + 1;
|
|
|
|
|
I was tasked to write a program asks the user for the name of a file. The program should display the contents of the file with each line preceded witha line number followed by a colon. The line numbering should start at 1.
I got to the point of displaying the content in the file but I am not sure how to code for the line numbers and colons. Any suggestions?
Here is what I have so far:
import java.util.Scanner; // Needed for the Scanner class
import java.io.*; // Needed for the File class
/**
This program reads data from a file.
*/
public class LineNumbers
{
public static void main(String[] args) throws IOException
{
// Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);
// Get the filename.
System.out.print("Enter the filename: ");
String filename = keyboard.nextLine();
// Open the file.
File file = new File(filename);
Scanner inputFile = new Scanner(file);
// Read lines from the file until no more are left.
while (inputFile.hasNext())
{
// Read the next name.
String familyName = inputFile.nextLine();
// Display the last name read.
System.out.println(familyName);
}
// Close the file.
inputFile.close();
}
}
|
|
|
|
|
You're a beginner therefore at some point recently you should have counted from 1 to 10 in a loop.
Fill in the blanks.
int lineNumber = 1;
while(....)
{
....
System.out.println(lineNumber + ": " + ....);
lineNumber++;
}
ps. Please put your code in <pre></pre> tags; as it makes it more readable.
If at first you don't succeed, you're not Chuck Norris.
|
|
|
|
|
Here is what you should do
<br />
int lines = 1;<br />
while (inputFile.hasNext())<br />
{<br />
String familyName = inputFile.nextLine();<br />
<br />
System.out.println( lines + " " + familyName + ";" );<br />
lines++;<br />
}<br />
Netmani
|
|
|
|
|
Thank you for your help. Works like a charm!!!!
|
|
|
|
|
Gentleman:
I just added a Java window to an ASP web page which shows an enlarged graphic. This works perfectly in Explorer, however it does something unusual in Firefox. Firefox opens a user request interface which asks the following:
What should Firefox do with this file:
Open With ... etc
or
Save
Neither option will open the new graphic in the Java window as it does in Explorer. Following is the code that I am using to open call the Window and get the graphic:
IN THE HEADER
<%--Large WIndow Scripts --%>
<script type="text/javascript">
function OpenLargeWindow1(image)
{
window.open("Ads/" + image, "", " width=760,height=300,top=200,left=200,scrollbars=0").focus();
}
</script>
IN THE BODY
<a href="javascript:OpenLargeWindow1('gears33.png')">
<asp:Image ID="Image18" runat="server" ImageUrl="~/Ads/plus_sign.png" /></a>
Does Firefox require a proprietary code or what option in the select process will put the graphic in the window if any? OR ???.
Any insight to this dilemma is appreciated.
Thank You, Pat
|
|
|
|
|
This is not a Java question but a Javascript question and is more applicable to the Web Development forum.
I believe Firefox downloads some file types rather than showing them and the same can be said for Internet Explorer, pdf's and png's for example. I would suggest creating a page which takes a 'get' variable which would then display the image on the page. Eg. javascript:OpenLargeWindow1('showimage.aspx?img=gears33.png') to avoid browser inconsistencies.
If at first you don't succeed, you're not Chuck Norris.
|
|
|
|
|
Fly,
Thank you for your reply. Being a Java novice, I do not understand the exact context of this code, but in fact, I have created a new page using your suggestion and with the graphics properly located, I am able to get the desired results in both browsers. It's a little long winded and I do not know if it is the best way to do it, but it works and I thank you for your input. Accordingly, I have marked your answer as correct and appreciate your help.
Re: Forum -- I apologize if I am "in the wrong place", but that is what comes from not knowing about a particular subject. I assumed that Java and Javascript are alike enough that a Java programmer would have the answer, since there is no category for Javascript. No offense was intended and I will use the other forum for future questions in this area. In fact, since the application is (.aspx), I also posted this question to the other (.Net) people, of which I am one, thinking this might be a common problem, but no one there replied to it. I am new to "Internet Applications" and I dislike this programming very much (all my experience comes from programming business desktop applications in C#), but in the words of the immortal John Wayne, "A Mans Got To Do What A Mans Got To Do!". Thank you again for your help...Pat
|
|
|
|
|
showimage.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<div>
<img src="<%= (Request["img"] != null) ? Request["img"] : "" %>" alt="img" />
</div>
</body>
</html>
Not really that hard tbh. Note that I wrote it on the fly so it may not be completely accurate.
If at first you don't succeed, you're not Chuck Norris.
|
|
|
|
|
i've 2 make a project can u suggest me some topic..
|
|
|
|
|
How about a program that suggests topics for new programs based on some questions asked etc..
If you get one working you should post it here. I'm sure it could be quite useful...
modified on Thursday, August 6, 2009 1:48 PM
|
|
|
|
|
thanx but dat wont work i think so..
if any other sugession den i'll b obliged.
|
|
|
|
|
Awww darn, you could save people a lot of trouble.
How about a chat server/client. That was one of the first apps I ever wrote and gives good practice communicating via network.
|
|
|
|
|
thanx but chat engine has been already made so i can repeat it.
sorry but dat also wont work.
oh im so sorry if im troubling u but i need some other topic.
|
|
|
|
|
can i use fwrite in java script like in php ? If yes then two line example please.
ThankYou
|
|
|
|
|
Do you mean Java (JSP) or Javascript?
You can't in Javascript, unless you want to use ActiveX.
If at first you don't succeed, you're not Chuck Norris.
|
|
|
|
|