Question 41. Q: My applet code in the use of JButton when the error is due to IE does not support swing package What should I do?
A: JButton is swing basic package Ah, as long as the Jdk/jre/lib/rt.jar put in the classpath on the line. Do not load any other libraries.
42. Q: Do not know whether Java support MIDI format, if supported, how to convert the wave format to MIDI format?
A: Not currently, you can look at the JMF three version of the MIDI format support is read only, and wave is Read/write,midi can only play, can not be generated.
43. Q: In the JSP inside to prevent users to enter the URL directly into the page, what should be done?
For:
One is control from the Web server, and all access to a directory is validated.
The second is to add control to the page you want to visit. This general session, but also with the request status code to achieve
44. Q:
For example, there is a computing application in the background (this program is very slow, can last a few minutes to a few hours, regardless, mainly can activate it), the client when the task is submitted, the server after the task to detect the error will send information to the server daemon, and activate it. Requirements are as follows:
1 First, the background program to activate, let it perform this task (for example, the front desk will calculate the C code submitted, the daemon program can immediately call and run it)
2 to display the running process information in the foreground JSP page (because of the long running time, want to let the customer see the information produced during the operation) how to complete?
For:
Live is OK, run a shell Let it run the background on the line, but it is not possible to remove the running information, because the HTTP timeout limit will not always wait for you to run the background, and information if you want to dynamic real-time launch of the server push technology.
45. Q: Database is a datetime, insert the current time to the database?
For:
Java.sql.Date sqldate = new Java.sql.Date ();
PreparedStatement pstmt = conn.preparestatement ("INSERT into foo (?)");
Pstmt.setdate (1,sqldate);
Pstmt.executeupdate ();
46. Q: How to remove the space before and after the string.
Answer: String.Trim ().
47. Q: How does session access variables of type int?
For:
Session.setattribute ("int", i+ "");
int i = Integer.parseint (Session.getattribute ("int"));
48. Q: How to keep the output float type data in JavaScript to two decimal places.
Answer: Math.Round (aaaaa*100)/100.
49. Q: How to call session in bean species.
For:
You can pass the session object as a parameter to the bean
Define the HttpServletRequest request in the bean; HttpSession session;
And then
Session = Request.getsession (false);
False to create a new session if the session is empty
Passes the session as a parameter. In fact, as long as the request is passed to
50. Q: How to display txt or Word files in the JSP page or servlet in the original format?
For:
In fact, a very simple solution is in the server's MIME to guide the text and Word interpretation, and then use a JSP or servlet to generate it on the line, the client will automatically invoke the appropriate program to open your document.
If you want to appear in the original format on the page instead of calling another program to open then you can try the WebDev protocol, which can be said to be a bright spot in Ms. It is a web-style open document, as is shared. Fully compliant requirements.
51. Q: Why is the Clone method of object not called directly?
For:
This method is protected in object
Why this method is defined as protected is a compromise, and its purpose is to know that your method is just a tag in object, not an implementation, such as \ r
public class Object
{
.............
Protected Object Clone ()
{}
}
So the direct inheritance of the Clone () method cannot be done any time you want to use this method to overload the method and relax the access rights to public or implement the Cloneable interface.
But it's not going to tell you that it's not really going to happen, it has to be warned by protected method.
52. Q: How do I refresh another page in one page?
For:
The requirement is that these face pages have to be associated, one is that they all have a common top-level frame, that is, a hierarchical page within a frame, of course, can be any level, frames can also be divided into frames, another may be the window pop-up windows, if there is no contact, it is impossible to use a page to refresh another page.
Only one-level reference within the frame is OK.
Like writing in a page in the left frame
Top.right.location.reload (), the page in the right frame is refreshed.
Pop-up, with the name of Open Refresh Child window, child window with opener Refresh main window
53. Q: How to write cookies to clients in JSP?
For:
Cookie COO = new Cookie (name, value);
Httpservletresponse.addcookie (name);
54. Q: Why Jtextfield1.settext ("aaabbb"); Jtextfield2.settext ("aaabbb"); Do you get a different font width?
A: It means that if you don't specify the width of the font, each font is different. So in Java, use the FontMetrics class to get the width of the characters.
55. Question: String kk=application/octet-stream; Name= "G:/smbcrack.exe"; How to get SMBCrack.exe?
For:
This should be the time to parse the upload of the binary stream to get
This line inside the format is fixed, take the Name= "after the string, and then put";
Then take the last/following all the characters to form a new string on the line.
56. Q: How to pass the value does not refresh the page?
For:
Pop-up a page for the selection of values or input, OK use to pass the value to the original window, use JavaScript to close the open window can:
Window.close (); Opener.focus ();
57. Q: There is a string: "Ef0c114ea4", how to become a[0] = 0xEF a[1] = 0x0C a[2] = 0x11 a[3] = 0x4e a[4] = 0xa4?
For:
String str= "ef0c114ea4f";
Out.print (str+ "<br>");
int l=str.length ()/2+str.length ()%2,j=0,k=0;
String[] A=new string[l];
for (int i=0;i<l;i++) {
if (Str.length ()-j==1)
K=str.length ();
Else
k=j+2;
a[i]= "0x" +str.substring (j,k);
Out.print ("a[" +integer.tostring (i) + "]=" +a[i]+ "<br>");
j+=2;
}
58. Q: How do I convert an int to a four byte array?
For:
int x = 1234567;
Byte[] B = new Byte[4];
for (int i=0;i<b.length;i++)
{
B[i] = (x >> (i*8)) & 0xFF;
}
59. Q: What should be noted in the use of indexOf ()?
A: The parameter refers to from the first few (1,2,3, ... To start the search, and the return value refers to the location of the search (0,1,2,3 ...) note from zero.
60. Q: How do I add a button dynamically in a Java application?
For:
This involves the problem of a component redrawing, which exists before the panel is displayed, and if a panel is already displayed, can you see it on top? But if you have button A on the same panel, if you press it with Button B, If you give the entire panel a repeat, then a itself will be redrawn, its event monitoring is not, of course, will not add B, so if you want to have another panel, when press A to put B on the panel and redraw the paenl, in fact, the better way is to first add B to the panel, The same one is OK. Setvisiable it (flase) and set to True when you press A.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service