How do I make my button not pressable?

I have a problem I need to solve. When I comeinto my page without setting the searchway for the folders that should be loaded into my dropdownlist my jsp page crash. I need to change that so I still come in there but the deploy button and dropdownlists are not able to be pressable. Mayb show another button saying back or an text saying something about it. How do I do that?

I guess it is the catch that makes the jsp to fail.
JSP PAGE 
-------------- 


<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 

<form name="buildanddeploymentform" method="POST" action="buildanddeploy.html" > 
   

       <table border="0" cellspacing="3" cellpadding="1" width="100%"> 
           <tr> 
               <td width="20%">Name</td> 
               <td><a href=${server.url}>${server.name}</td> 
           </tr> 
           <tr> 
               <td width="20%">Hostname</td> 
               <td>${server.hostname}</td> 
           </tr> 
           <tr> 
               <td width="20%">Last deployed package</td> 
               <td>${server.pakke}</td> 
           </tr> 
           <tr> 
               <td width="20%">Url</td> 
               <td>${server.url}</td> 
           </tr> 
           <tr> 
               <td width="20%">Date of last successed deploy</td> 
               <td>${server.dateForLastChange}</td> 
           </tr> 
           <tr> 
               <td width="20%">Deploy this package on server</td> 
               <td><select name="cmbPakke" > 
                       <c:forEach var="file" items="${list}"> 
                           <OPTION value="${file}">${file}</OPTION> 
                       </c:forEach> 
                   </select></td> 
           </tr> 
           <tr> 
               <td width="20%">Delete Database</td> 
               <td><input type="checkbox" name="chkCheckBox" size="20" /></td> 
           </tr> 
           <tr> 
               <td width="20%">Using this deploy setup</td> 
               <td> 
                   <select name="cmbDeploy"> 
                       <c:forEach var="deployment" items="${deployments}"> 
                           <OPTION value="${deployment.value.name}">${deployment.value.name}</OPTION> 
                       </c:forEach> 
                   </select> 
                   <INPUT TYPE=SUBMIT ID=deploy value=Deploy name="deploy" style="height: 25px; width: 100px"/> 
               </td> 
           </tr> 
           <tr> 
               <td colspan="2"></td> 
           </tr> 
           <tr> 
               <td>Last Deploy log</td> 
               <td><hr /></td> 
           </tr> 
           <tr> 
               <td> </td> 
               <td>file details here.....</td> 
           </tr> 
       </table> 
           <input type="hidden" name="serverid" value="${server.id}"/> 
   

</form> 



---------------------------------------------------- 



public class NewBuildAndDeployServlet extends HttpServlet { 

   public NewBuildAndDeployServlet() { 
       super(); 
   } 

   @Override 
   protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, FileNotFoundException { 

       //Get servers 
       ServerDao serverdao = new ServerDao(); 
       String fileName = getServletContext().getInitParameter("serverFile"); 
       serverdao.setFilename(fileName); 
       Server server = new Server(); 
       Map<UUID, Server> servers = null; 
       try { 
           servers = serverdao.getServers(); 
       } catch (ClassNotFoundException ex) { 
       } 

       String id = request.getParameter("id"); 

       if (id != null) { 
           server = servers.get(UUID.fromString(id)); 
       } 

       //Get configurations 
       ConfigurationDao configurationdao = new ConfigurationDao(); 
       fileName = getServletContext().getInitParameter("configFile"); 
       configurationdao.setFilename(fileName); 
       Configuration configuration = new Configuration(); 

       try { 
           configuration = configurationdao.getConfigurations(); 
       } catch (ClassNotFoundException ex) { 
       } 

       File file = new File(configuration.getPackageRepository()); 
       List<String> list = FileUtil.traverse(file); 

       //Get deployments 
       DeploymentDao deploymentdao = new DeploymentDao(); 
       fileName = getServletContext().getInitParameter("deploymentFile"); 
       deploymentdao.setFilename(fileName); 
       Map<UUID, Deployment> deployments = null; 
       try { 
           deployments = deploymentdao.getDeployments(); 
       } catch (ClassNotFoundException ex) { 
       } 

       // include server details in the request (for rendering) 
       request.setAttribute("deployments", deployments); 
       request.setAttribute("list", list); 
       request.setAttribute("server", server); 

       // forward request to jsp for rendering 
       request.getRequestDispatcher("/WEB-INF/jsp/buildanddeploymain.jsp").forward(request, response); 
   } 

   @Override 
   protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, FileNotFoundException { 

       String pakke = request.getParameter("cmbPakke"); 
       String deploySetup = request.getParameter("cmbDeploy"); 

       try { 
           //Get servers 
           ServerDao serverdao = new ServerDao(); 
           String fileName = getServletContext().getInitParameter("serverFile"); 
           serverdao.setFilename(fileName); 
           Server server = new Server(); 
           Map<UUID, Server> servers = null; 
           servers = serverdao.getServers(); 

           String id = request.getParameter("serverid"); 
           server = servers.get(UUID.fromString(id)); 
           Date date = server.getDateForLastChangeWithDate(); 
           Server newServer = server; 
           newServer.setDateForLastChange(date); 

           newServer.setPakke(pakke); 

           Deployment inputDeployment = new Deployment(); 

           //Get deployments 
           DeploymentDao deploymentdao = new DeploymentDao(); 
           fileName = getServletContext().getInitParameter("deploymentFile"); 
           deploymentdao.setFilename(fileName); 
           Map<UUID, Deployment> deployments = null; 
           deployments = deploymentdao.getDeployments(); 

           for (Deployment deployment : deployments.values()) { 
               if (deployment.getName().equalsIgnoreCase(deploySetup)) { 
                   inputDeployment = deployment; 
               } 
           } 

           String url = "http://" +newServer.getHostname() +":" +server.getPort() +inputDeployment.getUrl(); 
           newServer.setUrl(url); 
           newServer.setDeployment(inputDeployment); 
           serverdao.removeServer(server); 
           serverdao.addServer(newServer); 
            
           //Get configurations 
           ConfigurationDao configurationdao = new ConfigurationDao(); 
           fileName = getServletContext().getInitParameter("configFile"); 
           configurationdao.setFilename(fileName); 
           Configuration configuration = configurationdao.getConfigurations(); 

           PackageDeployer pd = new PackageDeployer(newServer, configuration); 
           pd.start(); 

       } catch (ClassNotFoundException ex) { 
       } 

       response.sendRedirect("/MyPage/index.html"); 
   } 
}

Open in new window

MickeysAsked:
Who is Participating?
 
scorneoConnect With a Mentor Commented:
If I understood your problem - u can do like if searchaway is null then you can write
<input name="" value=" any thing" ( here on condition print disabled) >
0
 
MickeysAuthor Commented:
I am not intrested in using javascript.

I have manage not to make the jsp page to crash. This:
List<String> list = FileUtil.traverse(file);
returns null if its not a directory. So how can I manage to get a value forexample.
flag = false over to the jsp page and disable the button and combobox?

request.setAttribute("flag", flag);     and then what in the html code/jsp page?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.