Passing parameters from a Java class to Jsp page

Hi everybody. I'm newbie in using Java class in conjunction with JSP pages. Infact I have a problem. How can I pass the parameters used in a Java class (as UserName, Password, and so on..) to a JSP page? What methods (and classes) I have to use?
Thank you in advance
Have a nice day

It still doesn't work. I write the code
//my java class
package channel_service;
import java.util.Vector;
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
public class CallMenu {
private Vector parameters = new Vector();
public void setParameters( String UserId ) {
parameters.add(0, UserId);
//parameters.add(2, Pin);
//parameters.add(3, UserName);
//parameters.add(4, Greeting);
public Vector getParameters() {
return parameters;
//my jsp page
<%@ page import="Channel_Service.src.channel_service.CallMenu" %>
<%@ page import="java.util.Vector" %>
<html>
<head><title>User Menu Page</title></head>
<body>
<center><h1><i><b>This is your personal User Menu page</b></i></h1></center>
<br>
<br>
<center><h2><i>In the list below you'll find all your personal information (as UserID, Password and so on...)
and all the function you have the rights to use</i></h2></center>
<br>
<br>
<table align=center>
<tr>
<%
CallMenu cl = new CallMenu();
cl.setParameters();
Vector params = cl.getParameters();
String UserId = (String)params.elementAt(0);
String Pin = (String)params.elementAt(1);
String UserName = (String)params.elementAt(2);
String Greeting = (String)params.elementAt(3);
%>
<td><h2><b><i>User ID = <%= UserId %></td></tr>
<tr><td><h2><b><i>PIN = <%= Pin %></td></tr>
<tr><td><h2><b><i>User Name = <%= UserName %></td></tr>
<tr><td><h2><b><i>The system says <%= Greeting %></td></tr>
</table>
</body>

Similar Messages

  • Passing input parameters from an applet to a JSP page

    Hello all,
    Yes, its one of these questions which I have tried to find a solution from the already large number of postings but with no luck. I'm still a novice to Java/JSP so bear with me.
    Consider this scenario.
    1. An applet which has two input boxes (say First name and surname). 2. These parameters will be passed to a JSP page (so the applet will call a JSP page).
    3. The JSP will have have the necessary logic (or actually a JavaBean will) to connect to a database and add a new record with these parameters (first name and surname).
    I also need to consider editing/updating the record in the database. So a JSP page will connect to the database, retrieving the required record from the database and then display the parameters back in an applet in two input boxes (first name and surname) to be edited and saved again.
    I have been able to develop a similar application using simple HTML forms to add and update records in a database so I'm not worried about the database connectivity simply the issue of passing parameters from the applet to the JSP page and vice versa (for edit/update).
    Once i've managed to do this with input boxes, I can experiment with the other input types radios, checkboxes, select etc.
    Many thanks in advance,
    Assad

    create an URL object with u'r specified link of the java class and send the parameters..write trhis action in any buttonclick event in u'r applet.

  • Tag to take a java class in JSP page

    Hi,
    � need to get a tag to get a java class for example Test.java into a JSP page like MyJSP.jsp so that � can ,after doing this, call its methods, variables etc.
    Thank you !

    � know a way to do th�s us�ng JRun but the programme � have (NETBEANS IDE 3) does not accept �t.

  • Import java-classes in JSP-page

    Hi,
    I'm starting with JSP and with trying one of the first examples in the book "beginning J2EE 1.4" from wrox, i got following problem.
    i'm trying to import a java-class in the package CH03 with
    <%@ page import="Ch03.FaqCategories" %>but he didn't find the package Ch03.
    I try already many things and i have no idea of the cause of the problem. So it's difficult to give information that leads to the solution.
    Maybe helpfull is the direcory-structure:
    jsp-page: /Ch03/welcome.jsp
    java-classe: /Ch03/WEB-INF/classes/Ch03/FaqCategories.class
    If you need source-codes or other information, just ask.
    Thanks,
    Dennis

    Thank you,
    Your help was one step into the good direction and that problem is solved.
    The application work now with studio one, but if i try it to work it with a stand-alone tomcat server it doesn't work anymore. I go first try to solve this problem by my self or at least try to describe the problem more exactly, before i ask for new help.
    but if you have any idea, that's always welcome...
    with regards,
    Dennis

  • Ordinary java class and jsp page

    hi i want to use some java class(not javabean ) in my jsp . how do i import them and use them?

    You can just import the package into your JSP, and access it like any other class of the Standard Java API that you access.
    fun_one

  • How to use java class in jsp page of JSPProvider?

    Hello everybody.
    I created simple JSPProvider channel with portal amconsole and named it "jspprov1". Then I created "jspprov"1 directory under "/ets/opt/SUNWps/desktop/sampleportal". I put "index.jsp" in it. And it worked until I add this line into "index.jsp": <% @page import="jspprov1package.aclass1" %>. Then I created directory "jspprov1package" under "/ets/opt/SUNWps/desktop/classes" and put "aclass1.class" into it and into "/ets/opt/SUNWps/desktop/classes" itself. I created "aclass1.class" on the other machine (with no installed portal) in j2sdk1.4.1_02: "javac aclass1.java". The text of this class is simple:
    "package jspprov1package;
    public class aclass1{
    public int int_field = 10;
    But the page still don't work. It writes on the portal desktop "ERROR: Content is not available".
    Does anybody know why this happened?

    Sorry, there were mistakes in jsp page and java files.
    I maked the channel "show exceptions" and found them out.

  • Scope of a java class in JSP page

    Hi
    If I use a java bean using the
    <jsp:useBean
    id="beanSomeName"
    scope="page|request|session|applicaton
    I can specify the scope of of the bean after which I can assume it is Garbage Collected.
    However if I just create a new Java Class in a jsp bean ( I inherited this code ) what will be scope of this java class. When will it be Garbage collected.
    Is it Page scope?
    Thanks
    bib/-

    If you do
    <% MyClass c = new MyClass(); %>
    and don't do anything else to store it in the request or session than it is like page scope.
    if you do
    <%! MyClass c = new MyClass(); %>
    it is more like application scope.

  • Java class into jsp page

    hi i,m a beginnner
    how can i run my own java class into a JSP file?
    please help me!
    thanks

    If you understand the OO concepts and wrote the Java class right, then all you need to do is something like:YourJavaClass yourJavaClass = new YourJavaClass();
    yourJavaClass.doSomething();After all I rather recommend to use servlets for business logic instead of JSP (read: scriptlets).

  • Importing java classes into jsp page

    I'm trying to import java classes inside my jsp page, while doing that i am getting compilation error "package uma.natarajan.javaclasses" not found. I don't know where to copy the java files. i'm keeping my jsp files under public_html folder
              

    Hi uma,
              create uma\natarajan\javaclasses under weblogic_home\myserver and copy java
              classes(u want to import) to uma\natarajan\javaclasses and then u try.
              Concept is the java classes u import should be present in a classpath. Hope
              this may help u,
              Arun,
              [email protected]
              "uma natarajan" <[email protected]> wrote in message
              news:3a490bcb$[email protected]..
              > I'm trying to import java classes inside my jsp page, while doing that i
              am getting compilation error "package uma.natarajan.javaclasses" not found.
              I don't know where to copy the java files. i'm keeping my jsp files under
              public_html folder
              

  • Sharing java class among JSP pages. Urgent!

    Hi,
    I have a class A and two JSP pages P1 and P2 page.
    i need to share the class values in both the pages.
    that is, whatever am doing in class A through P1 should be impacted on P2.
    Please tell me how to do this.
    Thaks,
    Raja.

    Well then you might try
    session.setAttribute("myBean", myBean);and
    MyBean myBean = (MyBean) session.getAttribute("myBean");The session is common space for storing the user's objects if you want to keep them over multiple requests.
    The session is implicitly available to all JSPs and via the Request object in a servlet.
    If the information is common to all users, another alternative may be to implement it as a Singleton bean - or have a static instance of it. But that may not be what you actually want.

  • Passing vector between java class and jsp page

    Hi,
    I think this is similar to the last post but anyways maybe somebody can help us both out bontyh.....I am getting an error saying undefined variable or class when i try to access a Vector which was returned in a class.
    Anyways anyone got any ideas?

    Maybe if you give some more information...

  • Passing parameters from portlet to portlet on same page

    Hi,
    can anyone please give me an example with the code. I have read that i should be using some api's but , don't know where to write them.
    Thanks.

    Hi,
    What version of portal are u using.We have introduced the concept of Page Parameters in Portal 902 release which would do exactly the same thing. Where in a page parameter can be used b/w portlets on a page.
    Thanks,
    Anu

  • Java Classes and JSP`s (urgent)

    hi, my question is:
    How can i invoke normal java classes` methods using Jsp`s for this??, is it possible??, if it is, then how do you do this, and where do you have to put the java classes in order to find them from a jsp.
    thanks

    Hi,
    You can access normal java classes in JSP pages. You have to import them in the header like this:
    <%@ page language="java" import="//your java class file with package"%>
    or if u r using java beans, then use the <usebean> tag. Put the java classes in the classes directory. Which server u r using? If it is JWS, then u have a specified classes directory, where u have to put all the class files along with their packages. Hope this will help.
    atanu.

  • Passing numerical variables to and from a Java class

    I'm trying to do something that seems like it should be fairly simple, but apparently it isn't. I'm new to Java and JDBC, so I'm hoping that I'm missing something fundamental and fairly basic.
    Basically, I want to pass a set of (number) variables to a Java class from a PL/SQL Procedure, and get back a series of numbers based on calculations to the first set of numbers. (In my real world project, I have to perform a series of matrix calculations to determine regression parameters for two sets of data, but we'll keep this simple.) However, I can find nothing that tells me how to do this, and I'm receiving a series of errors when I attempt it.
    For example, let's say I want to send in two decimal numbers, a and b, and receive back the sum s, the difference d, the product p and the quotient q. So, the java class would be:
    * MathEx.java
    class MathEx {
    public static void main(double a, double b, double sum, double diff, double prod, double quo) {
    sum = a + b;
    diff = a - b;
    prod = a * b;
    quo = a / b;
    Fairly simple, right? It compiles fine using "javac MathEx.java", and then I load the class into the database:
    loadjava -u steve/steve MathEx.class
    Everything works great. Now, I create a wrapper Procedure. This is where the problem comes in. How do I declare the incoming and outgoing parameters in the Procedure? No matter what I try, I get " the declaration of "MathEx.main([whatever])" is incomplete or malformed"
    The procedure I'm trying is:
    create or replace procedure Call_MathEx
    a NUMBER,
    b NUMBER,
    s NUMBER,
    d NUMBER,
    p NUMBER,
    q NUMBER
    AS
    language JAVA
    name 'MathEx.main(oracle.sql.NUMBER,oracle.sql.NUMBER,
    oracle.sql.NUMBER,oracle.sql.NUMBER,oracle.sql.NUMBER,oracle.sql.NUMBER,)';
    I've tried the following values for possible variable types in the "name 'MathEx.main(" statement:
    oracle.sql.NUMBER
    java.lang.Number
    java.lang.Double
    java.Math.BigDecimal
    The only thing I can get to work is if I just use "java.lang.string[]" and send everything at once, then use parseDouble() to read the parameters inside the Java class. However, that makes it impossible to then read the new values of the sum, difference, product and quotient in the calling procedure, since the variable retain the same value as before the call to the Java class.
    Any help is greatly appreciated.

    Java Stored Procedures Developers Guide (part of the docs and here on OTN) would probably help.
    I suspect you need:
    create or replace procedure Call_MathEx
    a IN NUMBER,
    b IN NUMBER,
    s OUT NUMBER,
    d OUT NUMBER,
    p OUT NUMBER,
    q OUT NUMBER
    AS
    language JAVA
    name 'MathEx.main(oracle.sql.NUMBER,oracle.sql.NUMBER,
    oracle.sql.NUMBER,oracle.sql.NUMBER,oracle.sql.NUMBER,oracle.sql.NUMBER,)';
    Not sure, I always let JDeveloper handle it for me :)

  • Issue with passing parameters from JSP to Backing bean

    hi ,
    I have an issue in passing parameters from my JSP to backing bean. I want to fetch the parameter from my URL in backing bean .This is how i am coding it right now. But the parameter companyID returns me null.
    URL http://localhost:8080/admin/compadmin.jsp?companyID=B1234.
    In my backing bean
    FacesContext context = FacesContext.getCurrentInstance();
    String companyID = (String)context.getExternalContext().getRequestParameterMap().get("CompanyID");
         public void setCompanyID(String companyID)
              this.companyID=companyID;
         public String getCompanyID()
              return this.companyID;
    faces-config.xml :
       <managed-bean-name>admincontroller</managed-bean-name>
              <managed-bean-class>com.admin.controller.AdminController</managed-bean-class>
              <managed-bean-scope>request</managed-bean-scope>
              <managed-property>
                   <property-name>companyadminbean</property-name>
                   <property-class>com.admin.model.AdminBean</property-class>
                   <value>#{companyadminbean}</value>
                         </managed-property>
                        <managed-property>
                                 <property-name>companyID</property-name>
                              <value>#{param.companyID}</value>
                             </managed-property>Please let me know if iam missing something.Appreciate your help in advance
    Thanks

    Thanks very much for your input. I made changes to my bean accordingly. Actually the method getAdminType() is a not a getter of a property. It's just a method which iam calling in AdminController bean constructor to verify whether the person is System Admin or Client admin. So now the issue is inspite of making changes still the link "Copy Users" shows up for Client admin too which is incorrect.
    My Administrator bean:
    public class Administrator {
      boolean GSA=false;
      boolean SA=false;
      public Administrator(){}
    public boolean isGSA()
        return GSA;
      public boolean isSA()
        return SA;
      public void setGSA(boolean value)
        this.GSA=value;
      public void setSA(boolean value)
        this.SA=value;
    }My backing bean:
    public class AdminController {
    private AdminBean adminbean = new AdminBean();
    public AdminController(){
    int userID=1234;
    this.getAdminType(userID);           
    public void getAdminType(int userID)
             Administrator admin = new Administrator();
             if (userID<0) return;
             try{
                 if(Rc.isGlobalSystemAdmin(userID)){
                      admin.setGSA(true);
                              }else if(Rc.isClientSystemAdmin(userID)){
                      admin.setSA(true); // i could see these values setup correctly in the admin bean when i print them
                 adminbean.setAdmin(admin);
                  } catch (Exception e){ }
    Admin Bean:
    public class AdminBean {
    private Administrator admin; 
    public Administrator getAdmin()
                        return this.admin;
              public void setAdmin(Administrator admin)
                        this.admin = admin;
    faces-config.xml
    <managed-bean>
              <managed-bean-name>admincontroller</managed-bean-name>
              <managed-bean-class>com.controller.AdminController</managed-bean-class>
              <managed-bean-scope>request</managed-bean-scope>
              <managed-property>
                   <property-name>adminbean</property-name>
                   <property-class>com.model.AdminBean</property-class>
                   <value>#{adminbean}</value>
             </managed-property>
         </managed-bean>
         <managed-bean>
              <managed-bean-name>adminbean</managed-bean-name>
              <managed-bean-class>com.model.AdminBean</managed-bean-class>
              <managed-bean-scope>request</managed-bean-scope>
              <managed-property>
                   <managed-property>
                   <property-name>admin</property-name>
                   <property-class>com.model.Administrator</property-class>
                   <value>#{admin}</value>
                             </managed-property>
         </managed-bean>     My JSP:<h:outputLink id="ol1" value="/companyadmin/copyusers.jsp">
               <h:outputText id="ot1" value="Copy Users" rendered="#{adminbean.admin.isGSA}" /><f:verbatim><br/></f:verbatim>
               </h:outputLink>    so now the issue is thelink copy users is displayed even #{adminbean.admin.isGSA} is FALSE. please advise.
    Thanks
    Edited by: twisai on Oct 15, 2009 7:06 AM

Maybe you are looking for

  • How to populate the fieldnames in the receiver file

    HI All, i got one requirement ie how to populate the fieldnames in the receiver file. please give the fast response. This is very urgent. thanks and regards sai

  • Add one song to iPhone 4

    For some reason the new itunes isn't allowing me to add just one song to my iPhone library.  I created a new playlist on my phone and don't want to choose the 'Sync Music' option (under Music heading when iPhone page is being viewed) because it tells

  • Entity reference causes multiple (split) child nodes

    Version: CXML Parser V.1.0.1 In the following --- <GeneSymbol>TGF-&;bgr;</GeneSymbol> ---the data is returned as THREE child ("#text") nodes instead of the expected one: (1) contains "TGF-", (2) contains "&", and (3) contains "bgr;". I expected (and

  • BAPI'S or Function Modules for creating BOM

    Hi all, Can any one please suggest me what is the exact function module or BAPI for creating BOM.. If any created the same through bapi's or FM your sample codes are also welcome.. Thanks and Regards, Keny

  • AE CS6 freezes while opening a project file

    Hi, I have been working on a project for past three days and this morning when I try to open the project, AE CS6 freezes at 66percent. And my MAC stops responding too. I need to force shut AE to get back in order. This is what I have already tried: -