OTUser
OTUser

Reputation: 3848

Calling java class form velocity template(.vt) file

I am working on velocity templates to fix some issue. Am new to this technology and am having hard time fixing this issue, please help me to fix this issue.

I need to call a java class from form velocity template(.vt) file, am doing the following

Am trying to get one of our application's url by calling the java class SCProperties

<#set ($partMatchURL = $txt.display($sCProperties.getProperty("partmatch.url")))>

SCProperties class is part of com.nfsmith.util package.

Then on clicking the Partmatch(below hyperlink) it should open a window with partmatch(one of our internal application) URL.

Following is the html code for the hyperlink

<div id="sub2tab10" class="subtab" style="left: 910" 
     onClick = "javascript:window.open('$partMatchURL');" 
     onMouseOver="hoversub(this);" 
     onMouseOut="setStateSub(2,10)">
  Part Match
</div>

But a herem gettinghttp://foo.bar.com/SalesChain3/Controller/`) url and below error

Am getting 500 error after clicking on the Partmatch hyperlink

HTTP Status 500 - 
type Exception report

message 

description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

javax.servlet.ServletException: Unable to find resource ')'
    com.nfsmith.servlet.Controller.error(Controller.java:683)
    org.apache.velocity.servlet.VelocityServlet.doRequest(VelocityServlet.java:361)
    org.apache.velocity.servlet.VelocityServlet.doGet(VelocityServlet.java:292)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


root cause 

org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource ')'
    org.apache.velocity.runtime.resource.ResourceManager.getResource(ResourceManager.java:438)
    org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:736)
    org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:718)
    org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleton.java:337)
    org.apache.velocity.servlet.VelocityServlet.getTemplate(VelocityServlet.java:499)
    com.nfsmith.servlet.Controller.handleRequest(Controller.java:626)
    org.apache.velocity.servlet.VelocityServlet.doRequest(VelocityServlet.java:331)
    org.apache.velocity.servlet.VelocityServlet.doGet(VelocityServlet.java:292)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

Upvotes: 0

Views: 984

Answers (1)

Edd
Edd

Reputation: 8570

Your question is very hard to follow. If I'm right then the following is true:

$txt.display($sCProperties.getProperty("partmatch.url")) results in http://foo.bar.com/SalesChain3/Controller/) (including the closing bracket)

I don't know what $txt.display() is supposed to do as you haven't explained it so I'll ignore it

If $sCProperties.getProperty("partmatch.url") is responding with http://foo.bar.com/SalesChain3/Controller/) then is sounds like you are successfully calling the method you want to and that the issue is in the method itself giving the wrong result

Upvotes: 1

Related Questions