Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8472613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:07:28+00:00 2026-06-10T17:07:28+00:00

I have a java we application that is working with velocity. I get two

  • 0

I have a java we application that is working with velocity. I get two variables in the first page via url that I extract using ureq.getParameter() method. One of the other classes that has a velocity container and I need to send one of the variables from the url to this velocity container. I tried creating an instance of the first class in the second class and using getVariable name method to do that but it did not work. Can someone tell me how I can do this?

Class 1:

package org.olat.dispatcher;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.olat.core.gui.UserRequest;

public class RemoteLoginformDispatcher implements Dispatcher {

    private static final String PARAM_newUrl = "ret";
    private static String newURL;

    @Override
    public void execute(
            final HttpServletRequest request, 
            final HttpServletResponse response, 
            final String uriPrefix) {

        UserRequest ureq = null;

        try {
            ureq = new UserRequest(uriPrefix, request, response);
            newURL = ureq.getParameter(PARAM_newUrl);
        } catch () {
        }

    }

    public String getURL(){
        return newURL;
    }

}

Class 2:

public class BaseChiefController extends DefaultChiefController implements ContentableChiefController {
    //Velocity container mainvc created here. It interacts with a html file. Removed the code that would not really matter

    //mainvc.contextPut("newURL", "something");
    //The below statement works. When I try with something, the something appears in the html file.
    mainvc.contextPut("newURL", myLogin.getURL());      

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T17:07:29+00:00Added an answer on June 10, 2026 at 5:07 pm

    To create an instance of another class, simply create a “public CLASSNAME” method, and inside define all class variables with the “this” modfier. Then, call out the function you wish to use from that method, and when you want to use the class, just do “new CLASSNAME(args);”

    Although, I am not really sure I am understanding your question.

    Maybe this is your answer. You can use variables from one class to another class by making the variable static, then doing “CLASSNAME.VARIABLENAME = WHATEVER”.


    EDITED:

    Okay, so as far as I can tell, you are using a method to return a static value from the class, which is much slower than just doing “newURL”, RemoteLoginformDispatcher.newURL);.
    Why not try this, as it is probably faster, and it should always work if newURL is defined. Otherwise, you have a different problem, and newURL is not being defined. If this is the case, try printing the caught Exception.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a working prototype of a Java application that is using Apache Commons
I have a Java application that is managed using Maven. The project involves the
I have a standalone java application that fires up several JMS consumers using the
I have a few JAVA application that I monitor using JMX. I would like
I am working in a java swing application. In that application i have to
I have a Java application that I've been working on and I just realized
I have been working on a java application that has a connection to a
I have an Android application (java) that was working fine when compiled with the
I have a Java application that is working as a service. After several days
Sir, i am working in a java application.On that application i have to access

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.