0

I am not able to render the image inside the jsp. Everything else is working fine i.e. all the data is being renderred. its only the image which is causing the issue. And I know the path is correct

<img src="https://localhost/genesis/images/client-logo1.png" alt="Image not available">

or

<img src="/images/client-logo1.png" alt="Image not available">

The below code renders the jsp

HttpServletResponse charResponse = null;
     Locale locale = ProxyContextHolder.getProxyContext().getLocale();
    try {
        View view = jspViewResolver.resolveViewName(viewNameWithExtension , locale);
        StringWriter sw = new StringWriter();
        Object request = (ProxyContextHolder.getProxyContext()).getRequest();
        Object response = (ProxyContextHolder.getProxyContext()).getResponse();
        if (request != null &&  request instanceof HttpServletRequest
            && response != null &&  response instanceof HttpServletResponse) {
            HttpServletRequest httpReq = (HttpServletRequest) request;
            HttpServletResponse httpResp = (HttpServletResponse) response;
            charResponse = new CharResponseWrapper(httpResp);
            view.render(modelMap, httpReq, charResponse);
            html = charResponse.toString();
            //httpReq.getRequestDispatcher(viewNameWithExtension).include(httpReq, charResponse);
           // html = charResponse.toString();
        }
    }

i have tried a few approach but nothing seems to be working. The jsp is loaded into a jeditorPane and an image is created from it.

At max i can see is some sort of broken or unrenderred image with a sun and mountain... not sure what it is

Can someone please help me out with this?

Peyush Goel
  • 383
  • 2
  • 3
  • 13
  • Did you try set the return content type to image/png as default JSP will return text/html – Dr BDO Adams Nov 23 '12 at 15:12
  • Image type would be for the entire jsp and not for the above tag... isn't it. Sorry this is kind of new to me. What i am actually doing is defining this jsp, rendering a model and some data.... and then getting the jsp contents to JeditorPane so that i can have an image of the jsp. JeditorPane is being used just as a virtual pane and doesn't exists as this is a server side code. is it possible to set the image type to png and it returns me an image which could be used with the bufferred image reader or something else – Peyush Goel Nov 23 '12 at 17:25

1 Answers1

0

Is the /image prefix resolved by the code you listed for jsp ? I think it should be left alone...

damiankolasa
  • 1,508
  • 9
  • 8
  • /image is nothing but the folder inside the directory it would point to.... i.e Webcontent/image/imageName ...... i guess path is specified in this manner only.. correct me if i am wrong – Peyush Goel Nov 23 '12 at 17:05