Your JSP needs to create the new instance of Test ...
<% Test test = new Test() %>

Then you can do the rest of the JSP and it should work

<% String hello="Hello World" %>
<% test.setFoo(hello); %>
<%= test.getFoo() %>

Also, I don't know if you're new to Java as well as to JSP, but the standard
convention is to start class names with an uppercase letter so "test.java"
should be "Test.java"


-----Original Message-----
From: Arcady [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 04, 2001 12:31 PM
To: [EMAIL PROTECTED]
Subject: Passing a string from a JSP to a Java class and back.


This is an ultra simple one I would guess.

But for some reason I cannot get it to go...


I want to take a string of data and send it from the jsp
webpage over to a class.
Then have that class send it back to the webpage which puts
it on the screen.

In essense step one of a larger process.

My JSP would be something like this:

<% String hello="Hello World" %>
<% test.setFoo(hello); %>
<%=test.getFoo() %>


My java class would be:

test.java :

import java.util.*;

public class test {

        static public String foo;
        private test() {}
        static public void setFoo(String t) {
                foo = t;
        }
        static public String getGoo() {
                return foo;
        }
}


I assume I'm missing something very obvious here...
Oddly enough none of my books on JSP cover this topic.
They all cover more advanced things like putting and pulling
from SQL databases or whatever...
But nothing on this simple level of work.

So...
What exactly do I need to do to get that String to go in and
come back out again? :)


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to