Thursday, March 17, 2011

Name of the Server generated servlet class

Hi Guys,
Do you know the name of the Name of the web server generated servlet class???

for the test.jsp

the class file will created with the name test_jsp.class file which will be stored in  the directory



apache/work/Catalina/localhost/_/org/apache/jsp/

Thanks & Regards

Rajesh Kumar yuvaraj

Is it not possible to use System class inside JSP declarations ...

Hi Guys.....

have you ever tried to use the following code into your JSP


<%!
 System.out.println(" it is blunder");
 %>


because  jsp declarative tag is for jsp declarations only but not for the definitions


it is as simple as this


public class Demo{
System.out.println("hello world");// its is joke
public static void  main(String ar[]){
System.out.println("hello world from main");
 }

}
Thanks & Regards


Rajesh Kumar Yuvaraj

can we define the method inside of the jsp scriplet tag

Hi Guys,

Good Day....

Have you ever tried to define a method inside of the jsp scriplet tag.

what is my point is

<%
public void aMethod(){
-------------------------------
-------------------------------
-------------------------------
------------------------------


}

%>
this is not possible  try it guys....

Can we use the out (JSP implicit Object) Object in JSP declarative Tag

Hi Guys,

Have you ever tried to use the out object in the JSP Declarative Tag try it guys....

Actually you cannot use the out object directly in the JSP Declarative tag....

what i want to convey is try to understand the following code

<%!
        out.write("its a blunder");
        out.println("this is also blunder");
  %>

Thursday, March 10, 2011

Jar Signer in Java

Signing a jar is basically used to verify a trusted source. When you sign a jar with your digital signature (based on your private key), you place a mark into the jar file that could not have been done by anyone but you.

The signature is also a checksum of the Jar file, so if the jar get corrupted or modified in transit, the signature is invalid.

On the other side, your public key is placed into the keystore of the system that trust you. This will be used to verify your signature.

Currently, I believe this is mainly used for applets. Using signed jar files, and setting security properties on client browsers, applets can have access to disk, network, and other stuff that they don't normally have access to.



There are many ways by which you can sign a JAR file using jarsigner. One way would be:
jarsigner -keystore C:\working\mystore -signedjar sbundle.jar bundle.jar john 
On executing the command, you will be prompted for the store password and the private key password. Here, bundle.jar represents the jar file you'd like to sign using the private key of the user whose keystore alias is "john" in the keystore named "mystore" located in the directory c:\working. For details, see the jarsigner documentation


Wednesday, February 23, 2011

Can you Directly get the Browser Name and Version in the JSP?

Hai Guys,

There is no direct way to the get the Browser Name and version in the JSP.

check the following program.

copy the following code inside a JSP page.
<%!
String browserName = "";
String browserVersion = "";
String tmpResult = "";
String getBrowserVersion(String ua, int index) {
tmpResult=ua.substring(index,ua.length());
String temp[]=tmpResult.split(" ");
return temp[0].replaceAll(";","");
}
%>
<%
String _ua = (String) request.getHeader("User-Agent");
System.out.println(_ua);
if (_ua.contains("MSIE")) {
browserName = "Microsoft Internet Explorer";
browserVersion = getBrowserVersion(_ua, _ua.indexOf("MSIE ")+5);
}
if (_ua.contains("Firefox")) {
browserName = "FireFox";
browserVersion = getBrowserVersion(_ua, _ua.indexOf("Firefox/") +8);
}
if (_ua.contains("Chrome") && _ua.contains("Safari")) {
browserName = "Google Chrome";
browserVersion = getBrowserVersion(_ua, _ua.indexOf("Chrome/") +7);
}
if (_ua.contains("Safari") && _ua.indexOf("Chrome")==-1) {
browserName = "Safari";
browserVersion = getBrowserVersion(_ua, _ua.indexOf("Version/") +8);
}
out.print("BrowserName  : " + browserName + "<br>");
out.print("BrowserVersion  : " + browserVersion);
 %>
out put

BrowserName : FireFox
BrowserVersion : 3.6.13

 OR

 <%!     
String browserName = "";
String browserVersion = "";
String tmpResult = "";
String getBrowser(String ua, String splitcon, String name) {
String temp1[] = ua.split(splitcon);
for (String s : temp1) {
if(s.contains(name))
tmpResult = s.trim();
}
tmpResult = tmpResult.replaceAll(" ", "/");
String temp2[] = tmpResult.split("/");
return temp2[1];
}
%>
<%
String _ua = (String) request.getHeader("User-Agent");
if (_ua.contains("MSIE")) {
browserName = "Microsoft Internet Explorer";
browserVersion = getBrowser(_ua, ";", "MSIE");
}
if (_ua.contains("Firefox")) {
browserName = "FireFox";
browserVersion = getBrowser(_ua, " ", "Firefox");
}
if (_ua.contains("Chrome") && _ua.contains("Safari")) {
browserName = "Google Chrome";
browserVersion = getBrowser(_ua, " ", "Chrome");
}
if (_ua.contains("Safari") && _ua.indexOf("Chrome")==-1) {
browserName = "Safari";
browserVersion = getBrowser(_ua, " ", "Version");
}
out.print("BrowserName  : " + browserName + "<br>");
out.print("BrowserVersion  : " + browserVersion);
%>

OUT PUT

BrowserName : FireFox
BrowserVersion : 3.6.13

Thanks,

Keep Rocking.

Sunday, February 13, 2011

JAVA videos...

check this for java videos...

http://www.java-videos-promotions.blogspot.com/