473,406 Members | 2,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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="reportgen.*"%>
<%@ page import="java.lang.reflect.Array" %>
<jsp:useBean id="webAppConstants" scope="session"
class="reportgen.WebAppConstants">
</jsp:useBean>
<% webAppConstants.loadProperties(config); %>
<% session.setAttribute("WebAppConstants", webAppConstants);%>

<html>
<head>
<title></title>
....
....
<td bordercolor="#000000" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="340"
class="Text_Small">
<tr>
<td valign="top" height="72">
<%out.print(webAppConstants.WELCOME);%>
<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="Login.aspx.cs" Language="c#" AutoEventWireup="false"
Inherits="ReportGenerator.Login" %>
<%@ Import namespace="ReportGenerator" %>
<% ReportConstants reportConstants = new ReportConstants(); %>
<script Language="c#" runat="server">
ReportConstants reportConstants =
(ReportConstants)Session["ReportConstants"];
</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 3272
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 =
(ReportConstants)Session["ReportConstants"];

}
</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******@discussions.microsoft.com> wrote in message
news:CB**********************************@microsof t.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="reportgen.*"%>
<%@ page import="java.lang.reflect.Array" %>
<jsp:useBean id="webAppConstants" scope="session"
class="reportgen.WebAppConstants">
</jsp:useBean>
<% webAppConstants.loadProperties(config); %>
<% session.setAttribute("WebAppConstants", webAppConstants);%>

<html>
<head>
<title></title>
...
...
<td bordercolor="#000000" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0"
height="340"
class="Text_Small">
<tr>
<td valign="top" height="72">
<%out.print(webAppConstants.WELCOME);%>
<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="Login.aspx.cs" Language="c#" AutoEventWireup="false"
Inherits="ReportGenerator.Login" %>
<%@ Import namespace="ReportGenerator" %>
<% ReportConstants reportConstants = new ReportConstants(); %>
<script Language="c#" runat="server">
ReportConstants reportConstants =
(ReportConstants)Session["ReportConstants"];
</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******@discussions.microsoft.com> wrote in message
news:CB**********************************@microsof t.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="reportgen.*"%>
<%@ page import="java.lang.reflect.Array" %>
<jsp:useBean id="webAppConstants" scope="session"
class="reportgen.WebAppConstants">
</jsp:useBean>
<% webAppConstants.loadProperties(config); %>
<% session.setAttribute("WebAppConstants", webAppConstants);%>

<html>
<head>
<title></title>
...
...
<td bordercolor="#000000" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0"
height="340"
class="Text_Small">
<tr>
<td valign="top" height="72">
<%out.print(webAppConstants.WELCOME);%>
<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="Login.aspx.cs" Language="c#" AutoEventWireup="false"
Inherits="ReportGenerator.Login" %>
<%@ Import namespace="ReportGenerator" %>
<% ReportConstants reportConstants = new ReportConstants(); %>
<script Language="c#" runat="server">
ReportConstants reportConstants =
(ReportConstants)Session["ReportConstants"];
</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.NullReferenceException: 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.getElementById("database").value="<%
out.print(reportConstants.DBNAME); %>";
....

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 =
(ReportConstants)Session["ReportConstants"];

}
</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******@discussions.microsoft.com> wrote in message
news:CB**********************************@microsof t.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="reportgen.*"%>
<%@ page import="java.lang.reflect.Array" %>
<jsp:useBean id="webAppConstants" scope="session"
class="reportgen.WebAppConstants">
</jsp:useBean>
<% webAppConstants.loadProperties(config); %>
<% session.setAttribute("WebAppConstants", webAppConstants);%>

<html>
<head>
<title></title>
...
...
<td bordercolor="#000000" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0"
height="340"
class="Text_Small">
<tr>
<td valign="top" height="72">
<%out.print(webAppConstants.WELCOME);%>
<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="Login.aspx.cs" Language="c#" AutoEventWireup="false"
Inherits="ReportGenerator.Login" %>
<%@ Import namespace="ReportGenerator" %>
<% ReportConstants reportConstants = new ReportConstants(); %>
<script Language="c#" runat="server">
ReportConstants reportConstants =
(ReportConstants)Session["ReportConstants"];
</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******@discussions.microsoft.com> wrote in message
news:CB**********************************@microsof t.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="reportgen.*"%>
<%@ page import="java.lang.reflect.Array" %>
<jsp:useBean id="webAppConstants" scope="session"
class="reportgen.WebAppConstants">
</jsp:useBean>
<% webAppConstants.loadProperties(config); %>
<% session.setAttribute("WebAppConstants", webAppConstants);%>

<html>
<head>
<title></title>
...
...
<td bordercolor="#000000" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0"
height="340"
class="Text_Small">
<tr>
<td valign="top" height="72">
<%out.print(webAppConstants.WELCOME);%>
<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="Login.aspx.cs" Language="c#" AutoEventWireup="false"
Inherits="ReportGenerator.Login" %>
<%@ Import namespace="ReportGenerator" %>
<% ReportConstants reportConstants = new ReportConstants(); %>
<script Language="c#" runat="server">
ReportConstants reportConstants =
(ReportConstants)Session["ReportConstants"];
</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******@discussions.microsoft.com> wrote in message
news:E3**********************************@microsof t.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.NullReferenceException: 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.getElementById("database").value="<%
out.print(reportConstants.DBNAME); %>";
...

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 =
(ReportConstants)Session["ReportConstants"];

}
</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******@discussions.microsoft.com> wrote in message
news:CB**********************************@microsof t.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="reportgen.*"%>
> <%@ page import="java.lang.reflect.Array" %>
> <jsp:useBean id="webAppConstants" scope="session"
> class="reportgen.WebAppConstants">
> </jsp:useBean>
> <% webAppConstants.loadProperties(config); %>
> <% session.setAttribute("WebAppConstants", webAppConstants);%>
>
> <html>
> <head>
> <title></title>
> ...
> ...
> <td bordercolor="#000000" valign="top">
> <table width="100%" border="0" cellspacing="0" cellpadding="0"
> height="340"
> class="Text_Small">
> <tr>
> <td valign="top" height="72">
> <%out.print(webAppConstants.WELCOME);%>
> <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="Login.aspx.cs" Language="c#"
> AutoEventWireup="false"
> Inherits="ReportGenerator.Login" %>
> <%@ Import namespace="ReportGenerator" %>
> <% ReportConstants reportConstants = new ReportConstants(); %>
> <script Language="c#" runat="server">
> ReportConstants reportConstants =
> (ReportConstants)Session["ReportConstants"];
> </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***@DIESPAMMERSDIEtakempis.com> wrote in message
news:u2****************@TK2MSFTNGP12.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******@discussions.microsoft.com> wrote in message
news:CB**********************************@microsof t.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="reportgen.*"%>
<%@ page import="java.lang.reflect.Array" %>
<jsp:useBean id="webAppConstants" scope="session"
class="reportgen.WebAppConstants">
</jsp:useBean>
<% webAppConstants.loadProperties(config); %>
<% session.setAttribute("WebAppConstants", webAppConstants);%>

<html>
<head>
<title></title>
...
...
<td bordercolor="#000000" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0"
height="340"
class="Text_Small">
<tr>
<td valign="top" height="72">
<%out.print(webAppConstants.WELCOME);%>
<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="Login.aspx.cs" Language="c#" AutoEventWireup="false" Inherits="ReportGenerator.Login" %>
<%@ Import namespace="ReportGenerator" %>
<% ReportConstants reportConstants = new ReportConstants(); %>
<script Language="c#" runat="server">
ReportConstants reportConstants =
(ReportConstants)Session["ReportConstants"];
</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******@hotmail.com> wrote in message
news:ey**************@TK2MSFTNGP09.phx.gbl...
I really like this analogy.. can I quote you on it?
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:u2****************@TK2MSFTNGP12.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******@discussions.microsoft.com> wrote in message
news:CB**********************************@microsof t.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="reportgen.*"%>
> <%@ page import="java.lang.reflect.Array" %>
> <jsp:useBean id="webAppConstants" scope="session"
> class="reportgen.WebAppConstants">
> </jsp:useBean>
> <% webAppConstants.loadProperties(config); %>
> <% session.setAttribute("WebAppConstants", webAppConstants);%>
>
> <html>
> <head>
> <title></title>
> ...
> ...
> <td bordercolor="#000000" valign="top">
> <table width="100%" border="0" cellspacing="0" cellpadding="0"
> height="340"
> class="Text_Small">
> <tr>
> <td valign="top" height="72">
> <%out.print(webAppConstants.WELCOME);%>
> <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="Login.aspx.cs" Language="c#" AutoEventWireup="false" > Inherits="ReportGenerator.Login" %>
> <%@ Import namespace="ReportGenerator" %>
> <% ReportConstants reportConstants = new ReportConstants(); %>
> <script Language="c#" runat="server">
> ReportConstants reportConstants =
> (ReportConstants)Session["ReportConstants"];
> </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 =
> (ReportConstants)Session["ReportConstants"];
> </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["ReportConstants"] 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******@discussions.microsoft.com> wrote in message
news:01**********************************@microsof t.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******@discussions.microsoft.com> wrote in message
news:CB**********************************@microsof t.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="reportgen.*"%>
> <%@ page import="java.lang.reflect.Array" %>
> <jsp:useBean id="webAppConstants" scope="session"
> class="reportgen.WebAppConstants">
> </jsp:useBean>
> <% webAppConstants.loadProperties(config); %>
> <% session.setAttribute("WebAppConstants", webAppConstants);%>
>
> <html>
> <head>
> <title></title>
> ...
> ...
> <td bordercolor="#000000" valign="top">
> <table width="100%" border="0" cellspacing="0" cellpadding="0"
> height="340"
> class="Text_Small">
> <tr>
> <td valign="top" height="72">
> <%out.print(webAppConstants.WELCOME);%>
> <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="Login.aspx.cs" Language="c#"
> AutoEventWireup="false"
> Inherits="ReportGenerator.Login" %>
> <%@ Import namespace="ReportGenerator" %>
> <% ReportConstants reportConstants = new ReportConstants(); %>
> <script Language="c#" runat="server">
> ReportConstants reportConstants =
> (ReportConstants)Session["ReportConstants"];
> </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.public.dotnet.framework.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
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...
0
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 ...
3
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...
0
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...
1
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...
7
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...
2
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...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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,...
0
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...

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.