We are currently performing maintenance on Appian Community. As a result, discussions posts and replies are temporarily unavailable. We appreciate your patience.

How Appian plugins can be created by including jsp files

I am trying to create a simple Appian servlet plugin in which my servlet class need to redirect to a jsp page.


Since custom plugins are created as standalone project where should I place my jsp file ?

Do I require to import any other external jar files to run the jsp file?


  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi @greshmaj there is a similar discussion happened long back ago on forum, please have a look on this. Hope this will help you.

  • Ok. I can convert the jsp file to a servlet.But what about the css and js used in the jsp ?.I have used used custom as well as bootstrap js and css in my file.
  • 0
    Certified Lead Developer
    in reply to greshmaj
    I know, it's not a good idea, but, you can embed CSS and js code inside Servlet using print() or println() method of PrintWriter Class. where the response contentType will be text/html
  • css and js files altogether forms 30000+ line of code .I think it will be difficult to place all the codes in servlet.

    Is there any alternative solution?
  • 0
    Certified Lead Developer
    in reply to greshmaj
    Yes there is an another approach, don't know, whether that will fit to you requirement or not.

    => You can build a dynamic web application, and place your JSP, CSS and JS files under Web Content
    => Inside web.xml file, set the welcome page to your JSP file (above created), so that you can access it just by hitting URL/AppName instead of being URL/AppName/fileName.jsp

    => Generate it's .WAR file and deploy that into server.

    => While creating Servlet in Plugin, try creating a properties file under src, which will have key-value pair as:
    jspURL=http://myURL/MyAPP , Here jspURL wil be your Key and http://myURL/MyAPP is your value where you want to navigate
    from servlet. The reason behind going for .properties file, is to make this plugin Configurable without any additional Deployment,
    in case if the URL of this app changes.

    => In Servlet, you can use , response.sendRedirect(myURL);
    here myURL is a String type variable which holds the value for the key jspURL within properties file, which you will get using
    java.io.InputStream from ClassPath location as

    InputStream is=YourClassName.class.getClassLoader().getResourceAsStream("myFile.properties");
    java.util.Properties p=new java.util.Properties();
    p.load(is); //Here you need to handle the exception
    String myURL=p.getProperty("jspURL");
    is.close();

    response.sendRedirect(myURL); //So this will allow your servlet to communicate within or outside of the Container as well.


    So, it's something like, your Servlet will communicate to an another JSP page available in an another application, like Web Application Intercommunication.



    Hope, this might help you.
  • Ok.I can try this.
    But one more doubt.This plugin is deploying in local Appian server(a remote server) .If I deploy the war file in Apache tomcat server in my local machine and use that url in servlet , will work?
  • 0
    Certified Lead Developer
    in reply to greshmaj
    You can access this application (which contains JSP page) from anywhere using servlet using response.sendRedirect(myURL); method, but by any chance if you feel that, both of them may or may not be in same server, then you need to use public IP of the server(which will have war file containing JSP page) instead of local IP for redirecting through servlet. It will work.

    Because sendRedirect(...) Works within as well as outside of the container.

    For example, instead of http://172.0.0.1:8087/MyApp this URL, you can go for public IP for this server, so that it will be accessible from anywhere, like
    http://256.92.98.98:8087/MyApp, assume 256.92.98.98 is the public IP for this server. There are many vendors which allows you to deploy war file into their cloud server(internally uses Tomcat) free of cost, so you can try these sites, in case if your server don't have public IP.
Reply
  • 0
    Certified Lead Developer
    in reply to greshmaj
    You can access this application (which contains JSP page) from anywhere using servlet using response.sendRedirect(myURL); method, but by any chance if you feel that, both of them may or may not be in same server, then you need to use public IP of the server(which will have war file containing JSP page) instead of local IP for redirecting through servlet. It will work.

    Because sendRedirect(...) Works within as well as outside of the container.

    For example, instead of http://172.0.0.1:8087/MyApp this URL, you can go for public IP for this server, so that it will be accessible from anywhere, like
    http://256.92.98.98:8087/MyApp, assume 256.92.98.98 is the public IP for this server. There are many vendors which allows you to deploy war file into their cloud server(internally uses Tomcat) free of cost, so you can try these sites, in case if your server don't have public IP.
Children
No Data