473,599 Members | 3,160 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting from java beans to c#

Hi,

I have an existing web application with java beans that I wanne migrate to
ASP.NET using C#.

The existing web application has some jsp files that use java beans as
follows:

....
<%@ page language="java" import="reportg en.*"%>
<%@ page import="java.la ng.reflect.Arra y" %>
<jsp:useBean id="webAppConst ants" scope="session"
class="reportge n.WebAppConstan ts">
</jsp:useBean>
<% webAppConstants .loadProperties (config); %>
<% session.setAttr ibute("WebAppCo nstants", webAppConstants );%>

<html>
<head>
<title></title>
....
....
<td bordercolor="#0 00000" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="340"
class="Text_Sma ll">
<tr>
<td valign="top" height="72">
<%out.print(web AppConstants.WE LCOME);%>
<br>
Now I'm looking for a possibility to use/make some C# objects that behave
nearly the same way that java beans do. That means I want to use them in the
html-code of an aspx-file.

In the above example webAppConstants is a selfdefined java class. But
because of "<jsp:useBean.. ." the class is instantiated to webAppConstants and
can be used in the following html-code.

I tried the following solution that should give me an object from a session:

<%@ Page CodeBehind="Log in.aspx.cs" Language="c#" AutoEventWireup ="false"
Inherits="Repor tGenerator.Logi n" %>
<%@ Import namespace="Repo rtGenerator" %>
<% ReportConstants reportConstants = new ReportConstants (); %>
<script Language="c#" runat="server">
ReportConstants reportConstants =
(ReportConstant s)Session["ReportConstant s"];
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Tran0sitional//EN" >
<HTML>
....

But Session is unknown. So how do I get access to the session? Or is what
would be another solution.

Thanks in advance for any help.

Stephen
Nov 19 '05 #1
9 3290
I believe the problem is that you need to put your code in the page_load
event. ASP.Net, unlike classic ASP, is event driven. That is, there's an
page_load event which fires when the page first loads.

Try:

<script Language="c#" runat="server">
void page_load(){
ReportConstants reportConstants =
(ReportConstant s)Session["ReportConstant s"];

}
</script>
not really sure what the goal of: > <% ReportConstants reportConstants = new
ReportConstants (); %> is, since you are later overwriting it with the
session variable...why create a new instance only to have it overwritten?
but if you do need, it too should likely be placed in page_load.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Stephen H." <St******@discu ssions.microsof t.com> wrote in message
news:CB******** *************** ***********@mic rosoft.com...
Hi,

I have an existing web application with java beans that I wanne migrate to
ASP.NET using C#.

The existing web application has some jsp files that use java beans as
follows:

...
<%@ page language="java" import="reportg en.*"%>
<%@ page import="java.la ng.reflect.Arra y" %>
<jsp:useBean id="webAppConst ants" scope="session"
class="reportge n.WebAppConstan ts">
</jsp:useBean>
<% webAppConstants .loadProperties (config); %>
<% session.setAttr ibute("WebAppCo nstants", webAppConstants );%>

<html>
<head>
<title></title>
...
...
<td bordercolor="#0 00000" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0"
height="340"
class="Text_Sma ll">
<tr>
<td valign="top" height="72">
<%out.print(web AppConstants.WE LCOME);%>
<br>
Now I'm looking for a possibility to use/make some C# objects that behave
nearly the same way that java beans do. That means I want to use them in
the
html-code of an aspx-file.

In the above example webAppConstants is a selfdefined java class. But
because of "<jsp:useBean.. ." the class is instantiated to webAppConstants
and
can be used in the following html-code.

I tried the following solution that should give me an object from a
session:

<%@ Page CodeBehind="Log in.aspx.cs" Language="c#" AutoEventWireup ="false"
Inherits="Repor tGenerator.Logi n" %>
<%@ Import namespace="Repo rtGenerator" %>
<% ReportConstants reportConstants = new ReportConstants (); %>
<script Language="c#" runat="server">
ReportConstants reportConstants =
(ReportConstant s)Session["ReportConstant s"];
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Tran0sitional//EN" >
<HTML>
...

But Session is unknown. So how do I get access to the session? Or is what
would be another solution.

Thanks in advance for any help.

Stephen

Nov 19 '05 #2
This is kind of hard to say, but you're putting the cart before the horse
here. What I mean is that, rather than trying to make ASP.Net behave like
Java Beans, or ASP, which is the closest thing in the Microsoft family to
Java Beans. You need to be thinking more about how to accomplish WHAT you
accomplish in Java Beans with ASP.net, not HOW. That is, any programming
technology exists for basically the same purpose: To satisfy requirements,
or to "make something happen." Session State, for example, exists for the
purpose of maintaining state acrosss a single user Session in a stateless
HTTP environment. And indeed, ASP.Net has Session State, and it serves the
same purpose. But you're talking about nailing nails with a hammer gun
instead of a hammer, and you want to know where to hit the nail with the
hammer gun. The end is the same; the means is entirely different. In other
words, you need to either bite the proverbial bullet, and learn how to work
with the ASP.Net object model, or stick with what you know. If you hit nails
with a hammer gun, eventually, the gun breaks. On the other hand, if you use
a hammer gun as it was designed, you can drive a lot more nails in a lot
less time.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Stephen H." <St******@discu ssions.microsof t.com> wrote in message
news:CB******** *************** ***********@mic rosoft.com...
Hi,

I have an existing web application with java beans that I wanne migrate to
ASP.NET using C#.

The existing web application has some jsp files that use java beans as
follows:

...
<%@ page language="java" import="reportg en.*"%>
<%@ page import="java.la ng.reflect.Arra y" %>
<jsp:useBean id="webAppConst ants" scope="session"
class="reportge n.WebAppConstan ts">
</jsp:useBean>
<% webAppConstants .loadProperties (config); %>
<% session.setAttr ibute("WebAppCo nstants", webAppConstants );%>

<html>
<head>
<title></title>
...
...
<td bordercolor="#0 00000" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0"
height="340"
class="Text_Sma ll">
<tr>
<td valign="top" height="72">
<%out.print(web AppConstants.WE LCOME);%>
<br>
Now I'm looking for a possibility to use/make some C# objects that behave
nearly the same way that java beans do. That means I want to use them in
the
html-code of an aspx-file.

In the above example webAppConstants is a selfdefined java class. But
because of "<jsp:useBean.. ." the class is instantiated to webAppConstants
and
can be used in the following html-code.

I tried the following solution that should give me an object from a
session:

<%@ Page CodeBehind="Log in.aspx.cs" Language="c#" AutoEventWireup ="false"
Inherits="Repor tGenerator.Logi n" %>
<%@ Import namespace="Repo rtGenerator" %>
<% ReportConstants reportConstants = new ReportConstants (); %>
<script Language="c#" runat="server">
ReportConstants reportConstants =
(ReportConstant s)Session["ReportConstant s"];
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Tran0sitional//EN" >
<HTML>
...

But Session is unknown. So how do I get access to the session? Or is what
would be another solution.

Thanks in advance for any help.

Stephen

Nov 19 '05 #3
Hi Karl,

I already tried this. The problem with this approach is that reportConstants
is only accessible in the scope of page_load. Even if I put the declaration
of reportConstants before the scope of page_load I get the runtime error
message "System.NullRef erenceException : Object reference not set to an
instance of an object."

I figured out another solution for the static parts because now I know how
to access html tags from the codebehind file.

But there's still one remaining problem: How do I access parts in
JavaScript. The following line is an example how it worked with Java:
....
document.getEle mentById("datab ase").value="< %
out.print(repor tConstants.DBNA ME); %>";
....

Bernd

"Karl Seguin" wrote:
I believe the problem is that you need to put your code in the page_load
event. ASP.Net, unlike classic ASP, is event driven. That is, there's an
page_load event which fires when the page first loads.

Try:

<script Language="c#" runat="server">
void page_load(){
ReportConstants reportConstants =
(ReportConstant s)Session["ReportConstant s"];

}
</script>
not really sure what the goal of: > <% ReportConstants reportConstants = new
ReportConstants (); %> is, since you are later overwriting it with the
session variable...why create a new instance only to have it overwritten?
but if you do need, it too should likely be placed in page_load.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Stephen H." <St******@discu ssions.microsof t.com> wrote in message
news:CB******** *************** ***********@mic rosoft.com...
Hi,

I have an existing web application with java beans that I wanne migrate to
ASP.NET using C#.

The existing web application has some jsp files that use java beans as
follows:

...
<%@ page language="java" import="reportg en.*"%>
<%@ page import="java.la ng.reflect.Arra y" %>
<jsp:useBean id="webAppConst ants" scope="session"
class="reportge n.WebAppConstan ts">
</jsp:useBean>
<% webAppConstants .loadProperties (config); %>
<% session.setAttr ibute("WebAppCo nstants", webAppConstants );%>

<html>
<head>
<title></title>
...
...
<td bordercolor="#0 00000" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0"
height="340"
class="Text_Sma ll">
<tr>
<td valign="top" height="72">
<%out.print(web AppConstants.WE LCOME);%>
<br>
Now I'm looking for a possibility to use/make some C# objects that behave
nearly the same way that java beans do. That means I want to use them in
the
html-code of an aspx-file.

In the above example webAppConstants is a selfdefined java class. But
because of "<jsp:useBean.. ." the class is instantiated to webAppConstants
and
can be used in the following html-code.

I tried the following solution that should give me an object from a
session:

<%@ Page CodeBehind="Log in.aspx.cs" Language="c#" AutoEventWireup ="false"
Inherits="Repor tGenerator.Logi n" %>
<%@ Import namespace="Repo rtGenerator" %>
<% ReportConstants reportConstants = new ReportConstants (); %>
<script Language="c#" runat="server">
ReportConstants reportConstants =
(ReportConstant s)Session["ReportConstant s"];
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Tran0sitional//EN" >
<HTML>
...

But Session is unknown. So how do I get access to the session? Or is what
would be another solution.

Thanks in advance for any help.

Stephen


Nov 19 '05 #4
Hi Kevin,

yes I have to learn more about ASP.Net. But metaphoric answers from people
who seem to come straight out of a DIY store are not really helpfull for
anybody.

Bernd
"Kevin Spencer" wrote:
This is kind of hard to say, but you're putting the cart before the horse
here. What I mean is that, rather than trying to make ASP.Net behave like
Java Beans, or ASP, which is the closest thing in the Microsoft family to
Java Beans. You need to be thinking more about how to accomplish WHAT you
accomplish in Java Beans with ASP.net, not HOW. That is, any programming
technology exists for basically the same purpose: To satisfy requirements,
or to "make something happen." Session State, for example, exists for the
purpose of maintaining state acrosss a single user Session in a stateless
HTTP environment. And indeed, ASP.Net has Session State, and it serves the
same purpose. But you're talking about nailing nails with a hammer gun
instead of a hammer, and you want to know where to hit the nail with the
hammer gun. The end is the same; the means is entirely different. In other
words, you need to either bite the proverbial bullet, and learn how to work
with the ASP.Net object model, or stick with what you know. If you hit nails
with a hammer gun, eventually, the gun breaks. On the other hand, if you use
a hammer gun as it was designed, you can drive a lot more nails in a lot
less time.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Stephen H." <St******@discu ssions.microsof t.com> wrote in message
news:CB******** *************** ***********@mic rosoft.com...
Hi,

I have an existing web application with java beans that I wanne migrate to
ASP.NET using C#.

The existing web application has some jsp files that use java beans as
follows:

...
<%@ page language="java" import="reportg en.*"%>
<%@ page import="java.la ng.reflect.Arra y" %>
<jsp:useBean id="webAppConst ants" scope="session"
class="reportge n.WebAppConstan ts">
</jsp:useBean>
<% webAppConstants .loadProperties (config); %>
<% session.setAttr ibute("WebAppCo nstants", webAppConstants );%>

<html>
<head>
<title></title>
...
...
<td bordercolor="#0 00000" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0"
height="340"
class="Text_Sma ll">
<tr>
<td valign="top" height="72">
<%out.print(web AppConstants.WE LCOME);%>
<br>
Now I'm looking for a possibility to use/make some C# objects that behave
nearly the same way that java beans do. That means I want to use them in
the
html-code of an aspx-file.

In the above example webAppConstants is a selfdefined java class. But
because of "<jsp:useBean.. ." the class is instantiated to webAppConstants
and
can be used in the following html-code.

I tried the following solution that should give me an object from a
session:

<%@ Page CodeBehind="Log in.aspx.cs" Language="c#" AutoEventWireup ="false"
Inherits="Repor tGenerator.Logi n" %>
<%@ Import namespace="Repo rtGenerator" %>
<% ReportConstants reportConstants = new ReportConstants (); %>
<script Language="c#" runat="server">
ReportConstants reportConstants =
(ReportConstant s)Session["ReportConstant s"];
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Tran0sitional//EN" >
<HTML>
...

But Session is unknown. So how do I get access to the session? Or is what
would be another solution.

Thanks in advance for any help.

Stephen


Nov 19 '05 #5
As is often the case, I have to agree with what Kevin also posted.

one question is why does this need to be done in javascript?

what is "database" ? a textbox? then you should do it like:

<asp:textbox id="database" runat="server" />

and in your codebehind use:

database.Text = reportContants. DBNAME;
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Stephen H." <St******@discu ssions.microsof t.com> wrote in message
news:E3******** *************** ***********@mic rosoft.com...
Hi Karl,

I already tried this. The problem with this approach is that
reportConstants
is only accessible in the scope of page_load. Even if I put the
declaration
of reportConstants before the scope of page_load I get the runtime error
message "System.NullRef erenceException : Object reference not set to an
instance of an object."

I figured out another solution for the static parts because now I know how
to access html tags from the codebehind file.

But there's still one remaining problem: How do I access parts in
JavaScript. The following line is an example how it worked with Java:
...
document.getEle mentById("datab ase").value="< %
out.print(repor tConstants.DBNA ME); %>";
...

Bernd

"Karl Seguin" wrote:
I believe the problem is that you need to put your code in the page_load
event. ASP.Net, unlike classic ASP, is event driven. That is, there's
an
page_load event which fires when the page first loads.

Try:

<script Language="c#" runat="server">
void page_load(){
ReportConstants reportConstants =
(ReportConstant s)Session["ReportConstant s"];

}
</script>
not really sure what the goal of: > <% ReportConstants reportConstants =
new
ReportConstants (); %> is, since you are later overwriting it with the
session variable...why create a new instance only to have it overwritten?
but if you do need, it too should likely be placed in page_load.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Stephen H." <St******@discu ssions.microsof t.com> wrote in message
news:CB******** *************** ***********@mic rosoft.com...
> Hi,
>
> I have an existing web application with java beans that I wanne migrate
> to
> ASP.NET using C#.
>
> The existing web application has some jsp files that use java beans as
> follows:
>
> ...
> <%@ page language="java" import="reportg en.*"%>
> <%@ page import="java.la ng.reflect.Arra y" %>
> <jsp:useBean id="webAppConst ants" scope="session"
> class="reportge n.WebAppConstan ts">
> </jsp:useBean>
> <% webAppConstants .loadProperties (config); %>
> <% session.setAttr ibute("WebAppCo nstants", webAppConstants );%>
>
> <html>
> <head>
> <title></title>
> ...
> ...
> <td bordercolor="#0 00000" valign="top">
> <table width="100%" border="0" cellspacing="0" cellpadding="0"
> height="340"
> class="Text_Sma ll">
> <tr>
> <td valign="top" height="72">
> <%out.print(web AppConstants.WE LCOME);%>
> <br>
>
>
> Now I'm looking for a possibility to use/make some C# objects that
> behave
> nearly the same way that java beans do. That means I want to use them
> in
> the
> html-code of an aspx-file.
>
> In the above example webAppConstants is a selfdefined java class. But
> because of "<jsp:useBean.. ." the class is instantiated to
> webAppConstants
> and
> can be used in the following html-code.
>
> I tried the following solution that should give me an object from a
> session:
>
> <%@ Page CodeBehind="Log in.aspx.cs" Language="c#"
> AutoEventWireup ="false"
> Inherits="Repor tGenerator.Logi n" %>
> <%@ Import namespace="Repo rtGenerator" %>
> <% ReportConstants reportConstants = new ReportConstants (); %>
> <script Language="c#" runat="server">
> ReportConstants reportConstants =
> (ReportConstant s)Session["ReportConstant s"];
> </script>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Tran0sitional//EN" >
> <HTML>
> ...
>
> But Session is unknown. So how do I get access to the session? Or is
> what
> would be another solution.
>
> Thanks in advance for any help.
>
> Stephen


Nov 19 '05 #6
I really like this analogy.. can I quote you on it?
"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:u2******** ********@TK2MSF TNGP12.phx.gbl. ..
This is kind of hard to say, but you're putting the cart before the horse
here. What I mean is that, rather than trying to make ASP.Net behave like
Java Beans, or ASP, which is the closest thing in the Microsoft family to
Java Beans. You need to be thinking more about how to accomplish WHAT you
accomplish in Java Beans with ASP.net, not HOW. That is, any programming
technology exists for basically the same purpose: To satisfy requirements,
or to "make something happen." Session State, for example, exists for the
purpose of maintaining state acrosss a single user Session in a stateless
HTTP environment. And indeed, ASP.Net has Session State, and it serves the
same purpose. But you're talking about nailing nails with a hammer gun
instead of a hammer, and you want to know where to hit the nail with the
hammer gun. The end is the same; the means is entirely different. In other
words, you need to either bite the proverbial bullet, and learn how to work with the ASP.Net object model, or stick with what you know. If you hit nails with a hammer gun, eventually, the gun breaks. On the other hand, if you use a hammer gun as it was designed, you can drive a lot more nails in a lot
less time.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

"Stephen H." <St******@discu ssions.microsof t.com> wrote in message
news:CB******** *************** ***********@mic rosoft.com...
Hi,

I have an existing web application with java beans that I wanne migrate to ASP.NET using C#.

The existing web application has some jsp files that use java beans as
follows:

...
<%@ page language="java" import="reportg en.*"%>
<%@ page import="java.la ng.reflect.Arra y" %>
<jsp:useBean id="webAppConst ants" scope="session"
class="reportge n.WebAppConstan ts">
</jsp:useBean>
<% webAppConstants .loadProperties (config); %>
<% session.setAttr ibute("WebAppCo nstants", webAppConstants );%>

<html>
<head>
<title></title>
...
...
<td bordercolor="#0 00000" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0"
height="340"
class="Text_Sma ll">
<tr>
<td valign="top" height="72">
<%out.print(web AppConstants.WE LCOME);%>
<br>
Now I'm looking for a possibility to use/make some C# objects that behave nearly the same way that java beans do. That means I want to use them in
the
html-code of an aspx-file.

In the above example webAppConstants is a selfdefined java class. But
because of "<jsp:useBean.. ." the class is instantiated to webAppConstants and
can be used in the following html-code.

I tried the following solution that should give me an object from a
session:

<%@ Page CodeBehind="Log in.aspx.cs" Language="c#" AutoEventWireup ="false" Inherits="Repor tGenerator.Logi n" %>
<%@ Import namespace="Repo rtGenerator" %>
<% ReportConstants reportConstants = new ReportConstants (); %>
<script Language="c#" runat="server">
ReportConstants reportConstants =
(ReportConstant s)Session["ReportConstant s"];
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Tran0sitional//EN" >
<HTML>
...

But Session is unknown. So how do I get access to the session? Or is what would be another solution.

Thanks in advance for any help.

Stephen


Nov 19 '05 #7
Why thank you Sean. All of my ramblings are copyright-free!

--
:-D,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Sean M" <ta******@hotma il.com> wrote in message
news:ey******** ******@TK2MSFTN GP09.phx.gbl...
I really like this analogy.. can I quote you on it?
"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:u2******** ********@TK2MSF TNGP12.phx.gbl. ..
This is kind of hard to say, but you're putting the cart before the horse
here. What I mean is that, rather than trying to make ASP.Net behave like
Java Beans, or ASP, which is the closest thing in the Microsoft family to
Java Beans. You need to be thinking more about how to accomplish WHAT you
accomplish in Java Beans with ASP.net, not HOW. That is, any programming
technology exists for basically the same purpose: To satisfy
requirements,
or to "make something happen." Session State, for example, exists for the
purpose of maintaining state acrosss a single user Session in a stateless
HTTP environment. And indeed, ASP.Net has Session State, and it serves
the
same purpose. But you're talking about nailing nails with a hammer gun
instead of a hammer, and you want to know where to hit the nail with the
hammer gun. The end is the same; the means is entirely different. In
other
words, you need to either bite the proverbial bullet, and learn how to

work
with the ASP.Net object model, or stick with what you know. If you hit

nails
with a hammer gun, eventually, the gun breaks. On the other hand, if you

use
a hammer gun as it was designed, you can drive a lot more nails in a lot
less time.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

"Stephen H." <St******@discu ssions.microsof t.com> wrote in message
news:CB******** *************** ***********@mic rosoft.com...
> Hi,
>
> I have an existing web application with java beans that I wanne migrate to > ASP.NET using C#.
>
> The existing web application has some jsp files that use java beans as
> follows:
>
> ...
> <%@ page language="java" import="reportg en.*"%>
> <%@ page import="java.la ng.reflect.Arra y" %>
> <jsp:useBean id="webAppConst ants" scope="session"
> class="reportge n.WebAppConstan ts">
> </jsp:useBean>
> <% webAppConstants .loadProperties (config); %>
> <% session.setAttr ibute("WebAppCo nstants", webAppConstants );%>
>
> <html>
> <head>
> <title></title>
> ...
> ...
> <td bordercolor="#0 00000" valign="top">
> <table width="100%" border="0" cellspacing="0" cellpadding="0"
> height="340"
> class="Text_Sma ll">
> <tr>
> <td valign="top" height="72">
> <%out.print(web AppConstants.WE LCOME);%>
> <br>
>
>
> Now I'm looking for a possibility to use/make some C# objects that behave > nearly the same way that java beans do. That means I want to use them
> in
> the
> html-code of an aspx-file.
>
> In the above example webAppConstants is a selfdefined java class. But
> because of "<jsp:useBean.. ." the class is instantiated to webAppConstants > and
> can be used in the following html-code.
>
> I tried the following solution that should give me an object from a
> session:
>
> <%@ Page CodeBehind="Log in.aspx.cs" Language="c#" AutoEventWireup ="false" > Inherits="Repor tGenerator.Logi n" %>
> <%@ Import namespace="Repo rtGenerator" %>
> <% ReportConstants reportConstants = new ReportConstants (); %>
> <script Language="c#" runat="server">
> ReportConstants reportConstants =
> (ReportConstant s)Session["ReportConstant s"];
> </script>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Tran0sitional//EN" >
> <HTML>
> ...
>
> But Session is unknown. So how do I get access to the session? Or is what > would be another solution.
>
> Thanks in advance for any help.
>
> Stephen



Nov 19 '05 #8
Well, Stephen,

I wouldn't be here if I was a pure DIY guy! I'd be off somewhere ignoring
the rest of the world.

Notice that I did mention that you have the option of sticking with what you
know. Otherwise, you're goint o have to put on your thinking cap for a very
long time, along with the rest of use exploring this incredibly vast world
of .Net technology.

But, so you don't feel that I've completely abandoned you to your own
devices, I can provide you with a small piece of information regarding the
code you posted:
> <% ReportConstants reportConstants = new ReportConstants (); %>
> <script Language="c#" runat="server">
> ReportConstants reportConstants =
> (ReportConstant s)Session["ReportConstant s"];
> </script>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Tran0sitional//EN" >
> <HTML>
> ...
>
> But Session is unknown. So how do I get access to the session? Or is
> what
> would be another solution.

I would guess that it isn't Session that is "unknown." It looks like
Session["ReportConstant s"] is null. I don't see where you've initialized it
prior to attempting to cast it as a ReportConstants class.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Stephen H." <St******@discu ssions.microsof t.com> wrote in message
news:01******** *************** ***********@mic rosoft.com... Hi Kevin,

yes I have to learn more about ASP.Net. But metaphoric answers from people
who seem to come straight out of a DIY store are not really helpfull for
anybody.

Bernd
"Kevin Spencer" wrote:
This is kind of hard to say, but you're putting the cart before the horse
here. What I mean is that, rather than trying to make ASP.Net behave like
Java Beans, or ASP, which is the closest thing in the Microsoft family to
Java Beans. You need to be thinking more about how to accomplish WHAT you
accomplish in Java Beans with ASP.net, not HOW. That is, any programming
technology exists for basically the same purpose: To satisfy
requirements,
or to "make something happen." Session State, for example, exists for the
purpose of maintaining state acrosss a single user Session in a stateless
HTTP environment. And indeed, ASP.Net has Session State, and it serves
the
same purpose. But you're talking about nailing nails with a hammer gun
instead of a hammer, and you want to know where to hit the nail with the
hammer gun. The end is the same; the means is entirely different. In
other
words, you need to either bite the proverbial bullet, and learn how to
work
with the ASP.Net object model, or stick with what you know. If you hit
nails
with a hammer gun, eventually, the gun breaks. On the other hand, if you
use
a hammer gun as it was designed, you can drive a lot more nails in a lot
less time.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Stephen H." <St******@discu ssions.microsof t.com> wrote in message
news:CB******** *************** ***********@mic rosoft.com...
> Hi,
>
> I have an existing web application with java beans that I wanne migrate
> to
> ASP.NET using C#.
>
> The existing web application has some jsp files that use java beans as
> follows:
>
> ...
> <%@ page language="java" import="reportg en.*"%>
> <%@ page import="java.la ng.reflect.Arra y" %>
> <jsp:useBean id="webAppConst ants" scope="session"
> class="reportge n.WebAppConstan ts">
> </jsp:useBean>
> <% webAppConstants .loadProperties (config); %>
> <% session.setAttr ibute("WebAppCo nstants", webAppConstants );%>
>
> <html>
> <head>
> <title></title>
> ...
> ...
> <td bordercolor="#0 00000" valign="top">
> <table width="100%" border="0" cellspacing="0" cellpadding="0"
> height="340"
> class="Text_Sma ll">
> <tr>
> <td valign="top" height="72">
> <%out.print(web AppConstants.WE LCOME);%>
> <br>
>
>
> Now I'm looking for a possibility to use/make some C# objects that
> behave
> nearly the same way that java beans do. That means I want to use them
> in
> the
> html-code of an aspx-file.
>
> In the above example webAppConstants is a selfdefined java class. But
> because of "<jsp:useBean.. ." the class is instantiated to
> webAppConstants
> and
> can be used in the following html-code.
>
> I tried the following solution that should give me an object from a
> session:
>
> <%@ Page CodeBehind="Log in.aspx.cs" Language="c#"
> AutoEventWireup ="false"
> Inherits="Repor tGenerator.Logi n" %>
> <%@ Import namespace="Repo rtGenerator" %>
> <% ReportConstants reportConstants = new ReportConstants (); %>
> <script Language="c#" runat="server">
> ReportConstants reportConstants =
> (ReportConstant s)Session["ReportConstant s"];
> </script>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Tran0sitional//EN" >
> <HTML>
> ...
>
> But Session is unknown. So how do I get access to the session? Or is
> what
> would be another solution.
>
> Thanks in advance for any help.
>
> Stephen


Nov 19 '05 #9
Kevin Spencer shared this with us in
microsoft.publi c.dotnet.framew ork.aspnet:
Why thank you Sean. All of my ramblings are copyright-free!


# rambling starts here

Do you mean Public Domain, Open License, Shared License, Creative
Common License, Open Publication license, or some other licensing
scam^Wscheme?
;-)

--
Amedee Van Gasse
Nov 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5786
by: Tushar | last post by:
Hello, I am working on a client server application involving TOMCAT as Web server, MySQl as the DB and combination of JSP, Servlet, and JavaBeans to access and write Data back. There is another piece of the project (out side my scope of development) that writes to the Same MySQL tables and make changes to the data.
0
9867
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ********************************** package Celcom.Client;
3
2325
by: Francis M | last post by:
Nowadays when you obtain the SDK form java.com you get a new interactive programming environemt much like the Borland C++ IDE. Up to now I've been developing applications "the old way" using the operating system command line method. that is, javac MyApp.java Then my computer at home crashed and I decided to install the JDK on my office computer. This was when I got the new
0
2128
by: donnet | last post by:
To those familiar with Java beans, question on how to do with ASP.NET: I come from J2EE and starting to learn ASP.NET and C#. I want to find a way to display a web form filled with data taken from a SQL table. I need to repeat the layout of my web form in one single page, each time with data taken from the SQL table row. I don't want to put those data rows into a datagrid because I have my own form that I want to populate with a specific...
1
2329
by: Andrea Temporin | last post by:
Is there someone who can tell me if it's possible to call Java Beans from Visual Basic Applications (windows forms application I mean)? Can I Use J#? Is It possible to create a Java web services as an interface to the Java bean? At now every people I know told me there is no way ... Thank You very much
7
4971
by: Christian Wilhelm | last post by:
Hi! I'm trying to call a Java WebService out of a .net Client. There are two Methods, one Method requires one Parameter of type Parameter, the other Method requires one Parameter of type Parameter. I can call the first Method without Problems, the Parameter can be deserialized by the WebService. But if I want to call the second Method and give it an Array of Parameters, then the following exception is thrown by the WebService:...
2
6943
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
4
1878
jeffbroodwar
by: jeffbroodwar | last post by:
Hi Guys, I just want to hear your understanding of Java Beans. I mean it doesn't just expose properties (for parameters) right? Java beans must be able to do what variables can't. i need feedbacks please. Thanks Regards, Jeff
0
7904
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8400
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8051
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8267
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6725
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5850
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3898
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2414
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1250
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.