It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to pass a value to a Java class from a .vm file

I have a velocity template page which contains list of entries and a button.On clicking the button i would like to open a page were i can add new entries which in-turn gets populated to the list.

Issue : On clicking the button, i could see the control is going to a Get Method in the Java class,but not able to obtain any values from the vm page . I will be able to open the new page based on the data passed from the velocity template page.

Please suggest what or were have i gone wrong.I had done various trials based on the comments in other quereis.

Below are the code snippet. I tried to call a function but the alert is not coming.But the related Java class is method is called, but the data from form is not obtained

VM File content



<meta name="decorator" content="atl.admin" />


< script type="text/javascript">
function validateField() {
<form id="admin" class="aui">

<div class="aui-page-panel">
<div class="aui-page-panel-inner">

<section class="aui-page-panel-content">

<div id="elements-admin-main">
<div data-reactroot="">
<h2>Global Configuration Checklist

<!-- <input type="submit" value="Create Global Config" class="aui-button aui-button-primary headerCreateBtn">-->
<input type="text" name="createField" value="create">
<button class="aui-button aui-button-primary headerCreateBtn" id="createGlobalConfig" onclick="validateField()">

<table class="aui">
<th>Issue type(s)</th>
<th>Last update</th>
<th>Updated By</th>

#foreach( $globalConfigurationDetails in $globalConfigurationDetailsList )
<td><a target="_blank" href="">Edit</a></td>

</section><!-- .aui-page-panel-content -->
</div><!-- .aui-page-panel-inner -->


JAVA class snippet


public class AdminServlet extends HttpServlet
private final UserManager userManager;
private final LoginUriProvider loginUriProvider;
private final TemplateRenderer renderer;

public AdminServlet(UserManager userManager, LoginUriProvider loginUriProvider, TemplateRenderer renderer)
this.userManager = userManager;
this.loginUriProvider = loginUriProvider;
this.renderer = renderer;

public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException

System.out.println("************************************ FROM PRODUCT PLUGIN ####################################");
System.out.println("************************************ Inside the GET Method........... @@@@@@@@@@@@@@@@@@@@@@@");
System.out.println("************************************ ************************************");

System.out.println("*************** ContextPath " +request.getContextPath());
//System.out.println("*************** Get Header " +request.getHeader());
System.out.println("*************** Path Info " +request.getPathInfo());
System.out.println("*************** Request URI " +request.getRequestURI());
System.out.println("*************** Servlet Path " +request.getServletPath());
System.out.println("*************** Request Get Attribute " +request.getAttribute("createField"));

Map<String, Object> context = new HashMap<String, Object> ();

String username = userManager.getRemoteUsername(request);
if (username == null || !userManager.isSystemAdmin(username))
redirectToLogin(request, response);

List<GlobalConfigurationDetails> globalConfigurationDetailsList = new ArrayList<GlobalConfigurationDetails>();

globalConfigurationDetailsList = DBUtils.fetchGlobalConfigurationDetails();

context.put("globalConfigurationDetailsList", globalConfigurationDetailsList);

* Fetch data from DB
// projectDetailsList = DBUtils.fetchProjectName();
System.out.println(" **************** Ïnside the Servelet :: projectDetailsList "+globalConfigurationDetailsList);
context.put("projectName", "Quality Engineering");


renderer.render("admin.vm", context, response.getWriter());






1 answer

1 accepted

Parameters can be accessed through "HttpServletRequest request" object you receive

See request.getParameter("createField") should give you the value "create"

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Agile

“No BS” technology solutions with Forty8Fifity

Hey there Community! My name is Vannya Vallejo, the Channel Communication Specialist at Atlassian and I want to help Atlassian users like you learn a little bit more about our Solution Partners and...

797 views 1 11
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you