<%
Cookie userCookie = new Cookie("user", "uid123");
userCookie.setMaxAge(60*60*24*365); // 1 year
response.addCookie(userCookie);
%>
Code in .NET :--
<%
System.Web.HttpCookie userCookie =
new System.Web.HttpCookie("user", "uid123");
System.DateTime dateTime = System.DateTime.Now;
System.TimeSpan timeSpan =
new System.TimeSpan(0, 0, 60*60*24*365); // 1 year
cookie.Expires = dateTime.Add(timeSpan);
Response.Cookies.Add(userCookie);
%>
Beans :--
Java code :--
public class Bean1 {
private String text = "Hello";
public Bean1 () {}
public String getText() {
return this.text;
}
public String setText(String text) {
this.text = text;
}
}
C# code :--
using System;
public class Bean1{
private string text = "Hello";
public Bean1() {}
public string Text
{
get { return text; }
set { text = value; }
}
}
Converting Servlets to ASP .NET code behind :--
Servlet sample code :--
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class SimpleServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, java.io.IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html><body>");
out.println("Simple Servlet Body");
out.println("</body></html>");
out.close();
}
}
ASP .NET code-behind sample :--
using System;
using System.Web;
using System.Web.UI;
public class SimpleServlet : System.Web.UI.Page
{
private void Page_Load(object sender, EventArgs args)
{
Response.ContentType = "text/html";
Response.Write("<html><body>");
Response.Write("Simple Servlet Body");
Response.Write("</body></html>");
}
}
Tag Library :--
JSP
ASP .NET
Tag Handler Class
JSP Tag Library Descriptor
JSP Tag Library Directive
ASP.NET Web User Controls
ASP.NET Web Custom Control
JSP tag lib Sample code :--
<!– JSP -->
<!– the source file is specified in the TLD -->
<%@ taglib uri="taglib.tld" prefix="tags" %>
<tags:sample />
Converting Java Applets to .NET Winforms control :--
Applet code :--
package helloWorldPackage;
public class HelloWorld extends Applet {
public void paint(Graphics g) {
g.drawString(getParameter("parameter1"), 25, 25);
}
public void init() {}
public void start() {}
public void stop() {}
}
.NET Winforms code :--
namespace HelloWorldPackage
{
public class HelloWorld : System.Windows.Forms.UserControl
{
string parameter1;
bool isActive;
public HelloWorld()
{
init();
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.DrawString(parameter1, Font,
new SolidBrush(ForeColor), 25, 25);
}
public void init()
{
this.GotFocus +=
new EventHandler(this.helloWorldControl1_Start);
this.LostFocus +=
new EventHandler(this.helloWorldControl1_Stop);
}
}
In order to post questions/comments, you must be logged-in. If you are not a member
yet, then signup, otherwise login. Once you
login then come back to this page and you'll see a form right here which will allow you
to post comments/questions.
Please note, one of the benefits of signing up is to be notified immediately by email everytime you receive a
reply to the thread you have subscribed.