Thursday, April 29, 2010

How to generate servlet source from a JSP


Understanding the XML view

The core JSP syntax is made up of scriptlets, actions, directives, expressions and declarations defined by the JSP specification. Web browsers do not understand JSP syntax as they do HTML. For the browser to display the contents of a JSP page, JRun must first compile the JSP source as a servlet which JRun then uses to generate the response. The response is HTML or whatever markup language is requested. However, the JSP-to-servlet compilation process is not a direct one. The JSP must first be transformed into XML.

The following steps occur when a JSP is requested for the first time:

  1. A client requests a JSP for the first time.
  2. JRun converts the JSP into a temporary XML representation called the XML view.
  3. JRun validates the XML view of the JSP page.
  4. JRun transforms the XML view into a .java class file that extends jrun.jsp.runtime.HttpJSPServlet and implements jrun.jsp.runtime.JRunJspPage. You can view the servlet's source code as described in "Viewing servlet source code".
  5. JRun compiles the new class into a servlet.
  6. The servlet generates the output based on the client request.

The following image shows the lifecycle of a JSP page when it is first requested by a client and finally compiled into a servlet. The servlet then returns the request to the client.

This images shows the flow of a JSP page when it is first requested by a client. The JSP page goes from *.JSP to XML View to *.JAVA to a compiled servlet. Then the servlet returns the request to the client.

Viewing servlet source code

You can view the source code of the servlet representation of the JSP page. You cannot view the XML view of the JSP page because it is only maintained in memory temporarily while JRun constructs the servlet.

JRun does not keep servlets generated from JSP source code by default. This section shows you how to configure JRun to keep the Java files and where to view them.

To keep generated JSPs:

  1. In the jrun_root/servers/jrun_server/SERVER-INF/default-web.xml file, set the JSPServlet's keepGenerated initialization parameter to true, as shown in the following example:
     <servlet>
         <servlet-name>JSPServlet</servlet-name>
         <servlet-class>jrun.jsp.JSPServlet</servlet-class>
         <init-param>
               <param-name>keepGenerated</param-name>
               <param-value>true</param-value>
         </init-param>
     </servlet>
  2. Delete the JSP class files in the web application's /WEB-INF/jsp directory.

    Doing this removes the already-generated servlet class files. JRun checks for the existence of the class file before recompiling a JSP. If the class files were still available, JRun would not recompile the JSP. JRun also checks the data/time stamp of the JSP, so you can change the JSP source code and save the JSP file to cause JRun to regenerate the Java source code and recompile the class.

  3. Restart the JRun server.
  4. Request the JSP.
  5. Open the JSP's generated Java class file (*.java) in the web application's /WEB-INF/jsp directory. JRun names the source code files starting with "jrun__" and appends version information to the name.

Source: http://livedocs.adobe.com



Tuesday, April 27, 2010

How to created a shortcut on Pocket PC


Some programs don't create a shortcut on the Pocket Pc, at the same time we don't have a quick option to create on inside of the Pocket PC, here we have a couple ways to create a shortcut on the device.


You need to synchronize your Pocket PC, when is ready, Go to My Computer on your desktop and click Mobile Device. Navigate to the program for which you want to create the shortcut.
Right-click the program and select Create Shortcut. Right-click the shortcut and select Cut. Go to the \Windows\Start Menu\ folder under Mobile Device on your desktop, right-click inside the folder, and select Paste to paste the shortcut into the Pocket PC's Start menu.


You can use a small application provided by Scott & Ce Appt. named "NewShortcut" to create shortcuts without the need for ActiveSync, you can get it from the next link:


http://www.scottandmichelle.net/scott/cestuff.html




Friday, April 16, 2010

'SQLOLEDB' Reported an Error. Execution Terminated by the Provider Because a Resource Limit was Reached



When running a query from a remote server I am getting the next error:
'SQLOLEDB' Reported an Error. Execution Terminated by the Provider Because a Resource Limit was Reached

The problem is that the remote query timeout setting in Microsoft SQL Server is set too low for the query to complete.

In order to fix the problem we need to reset the time out value on the remote query settings.
To check the current value, execute the following command in Query Analyzer:
sp_configure 'remote query timeout'

To reset the remote query setting, execute the following commands in Query Analyzer:
sp_configure 'remote query timeout', n
go
reconfigure with override
go

Where n is the new timeout value.
Using '0' for n will set the timeout to infinite timeout.
This update should be performed by, or with the input of the database administrator to ensure the new setting is appropriate for your environment.


Source:
http://support.microsoft.com/kb/966725




Monday, March 29, 2010

-- How to get the path of the assembly currently executing



In order to get the path of the current executing assembly in C#:

// Get the current running assembly code
System.Reflection.Assembly myAssembly = System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName;

//Now we can get the path where the current code is running
String myPath = System.IO.Path.GetDirectoryName(myAssembly);




Wednesday, March 17, 2010

No errors when debugging but breakpoints are not hit on Visual Studio



In order to fix this problem you need to be sure that all the modules in your project are enabled for debugging, some times the main is enabled but the rest are not, this would give you the apparency of no errors but breakpoints on the modules not enabled will cause the debugging to stop.

To enable debugging right click on each project and select "Properties".
A window like the one on the image below should appear.
On 'Enable ASP.NET Debugging" select "True"
Click "Apply" then close.
The debug has been enabled for this module, repeat the process for all projects.






Friday, March 12, 2010

Remote desktop connection "The local policy of this system does not permit you to logon interactively"



If you are not an administrator and try to use the Remote Desktop Connection tool, you may receive the following error message:

The local policy of this system does not permit you to logon interactively.

This issue occurs because the user account is not a member of the local Remote Desktop Users group.

To resolve this issue, add allowed users to the Remote Desktop Users list:
  1. Click Start, point to Settings, and then click Control Panel.
  2. Double-click System, and then on the Remote tab, click Select Remote Users.
  3. Click Add type in the user account name, and then click OK.

    If you are adding more than one user name, use a semicolon to separate the names.
Note: Adding users to the Remote Desktop Group requires that you are logged on through an administrator account.

Also, make sure that the Remote Desktop Users group has sufficient permissions to log on through Terminal Services. To do this, follow these steps:
  1. Click Start, click Run, type secpol.msc, and then click OK.
  2. Expand Local Policies, and then click User Rights Assignment.
  3. In the right pane, double-click Allow logon through Terminal Services. Make sure that the Remote Desktop Users group is listed.
  4. Click OK.
  5. In the right pane, double-click Deny logon through Terminal Services. Make sure that the Remote Desktop Users group is not listed, and then click OK.
  6. Close the Local Security Settings snap-in

Source:
http://support.microsoft.com




Wednesday, March 3, 2010

How to call a JavaScript function from a Java applet




Calling a JavaScript function from a Java applet is really simple; in order to approach it we need to use the showDocument method, see the example below of the Java applet:

import java.net.*;
import java.applet.*;


public class MyApplet extends Applet
{
public void init()
{
String msg = "Hello World...";

try {
URL _url = new URL("javascript: callme(\"" msg "\")"
getAppletContext().showDocument( _url) );
}
catch (MalformedURLException e) {
e.toString();
}
}
}


Next we need the JavaScript function:

<script language="JavaScript" type="text/javascript">
function callme(msg)
{
try{
alert(msg);
}
catch(e){
alert(e);
}
}
</script>

Finally we code the HTML code:

<APPLET CODE="MyApplet.class"
NAME="myApplet"
MAYSCRIPT
HEIGHT=15
WIDTH=15>
</APPLET>