About jsp source code

I have developed a very large web application. If there are any changes I need to make on a JSP page, it takes too long to find this JSP page, link, action, etc.

So, are there any tools or are there any methods thanks to which I can directly jump to the code of this particular JSP page?

I think "View Sources" is different. Does it show only the source of this JSP?

+5
source share
5 answers

Generate an HTML comment that identifies the source of each section of code directly in the final output, possibly in response to a query parameter of type "debugging". Then create the code using the "view source", and you should be able to figure out where it came from, pretty easily.

It will take time to add these comments to your code, but you can do it piecemeal with time when you change things.

0
source

Have you tried NetBeans or Eclipse or MyEclipse or any other IDE ? You can use the shortcuts of these tools to find the appropriate code in your application. They can help you find your JSP page in your application faster.

+4

- , , , jsp "", . addFriendAction.jsp. , , . JSP, . heres (Im , jsp MVC). - (. 4.8- http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/web-tier/web-tier5.html)

, , , .

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package servlets;

import beans.SeekerCustomer;
import java.io.*;
import java.util.HashMap;
import javax.servlet.*;
import javax.servlet.http.*;
/**
 *
 * @author Dhruv
 */

//servlet class acts as controller by delegating
//operations to the respective Action concrete subclass
public class ControllerServlet extends HttpServlet {

    //stores all the possible operation names
    //and operation objects for quick access
    private HashMap actions;

    @Override
    public void init() throws ServletException {
        actions = new HashMap();

        //all the various operations are stored in the hashmap
        CreateUserAction cua = new CreateUserAction(new SeekerCustomer());
        actions.put(cua.getName(), cua);
        ValidateUserAction vua = new ValidateUserAction(new SeekerCustomer());
        actions.put(vua.getName(), vua);
        ListNonFriendsAction lnfa = new ListNonFriendsAction(new SeekerCustomer());
        actions.put(lnfa.getName(), lnfa);
        AddFriendAction afa = new AddFriendAction(new SeekerCustomer());
        actions.put(afa.getName(), afa);
        ConfirmFriendReqAction cfra = new ConfirmFriendReqAction(new SeekerCustomer());
        actions.put(cfra.getName(),cfra);
        DeclineFriendReqAction dfra = new DeclineFriendReqAction(new SeekerCustomer());
        actions.put(dfra.getName(),dfra);
        AddImageAction aia = new AddImageAction(new SeekerCustomer());
        actions.put(aia.getName(),aia);
        ViewImageAction via = new ViewImageAction(new SeekerCustomer());
        actions.put(via.getName(),via);
        ViewAllImagesAction vaia = new ViewAllImagesAction(new SeekerCustomer());
        actions.put(vaia.getName(),vaia);
        AddTagAction ata = new AddTagAction(new SeekerCustomer());
        actions.put(ata.getName(),ata);
        ViewTagAction vta = new ViewTagAction(new SeekerCustomer());
        actions.put(vta.getName(),vta);
        ViewAllTagsAction vata = new ViewAllTagsAction(new SeekerCustomer());
        actions.put(vata.getName(),vata);
        ViewProfileAction vpa = new ViewProfileAction(new SeekerCustomer());
        actions.put(vpa.getName(),vpa);
        EditAccountAction epa = new EditAccountAction(new SeekerCustomer());
        actions.put(epa.getName(),epa);
        ViewOthersImageAction voia = new ViewOthersImageAction(new SeekerCustomer());
        actions.put(voia.getName(), voia);
        AddOthersTagAction aota = new AddOthersTagAction(new SeekerCustomer());
        actions.put(aota.getName(),aota);
        LogoutAction loa = new LogoutAction(new SeekerCustomer());
        actions.put(loa.getName(), loa);
        ToptagsAction tts = new ToptagsAction(new SeekerCustomer());
        actions.put(tts.getName(), tts);
        UpdateAccountAction uaa = new UpdateAccountAction(new SeekerCustomer());
        actions.put(uaa.getName(), uaa);
        ViewAllFriendsAction vafa = new ViewAllFriendsAction(new SeekerCustomer());
        actions.put(vafa.getName(), vafa);
        ReturnHomeAction rha = new ReturnHomeAction(new SeekerCustomer());
        actions.put(rha.getName(),rha);
    }

    public void processRequest(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {

        //identify the operation from the URL
        String op = getOperation(req.getRequestURL());
        //find and execute corresponding Action
        Action action = (Action)actions.get(op);
        Object result = null;
        try {
            //maintain the session between requests
            result = action.perform(req, resp);
            HttpSession session = req.getSession();
            session.setAttribute("session1", result);
        } catch (NullPointerException npx) {
            //nothing to handle
        }
    }

    //both GET and POST operations are directed to "processRequest" method
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }

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

    //uses the URL to identify the operation
    private String getOperation(StringBuffer requestURL) {

        String op="";
        //identifies the last index of "/" before ".do" and 
        //uses that to put each character after the "/" into "op"
        for(int i= requestURL.lastIndexOf("/",requestURL.indexOf(".do"))+1; i<requestURL.indexOf(".do"); i++)
        {
            op= op+requestURL.charAt(i);
        }
        return op;
    }
}

, , . , , CreateUserAction, CreateUserAction.java, CreateUserAction.jsp. , , , JSP . , - !

- JSP , JSP (. http://java.sun.com/developer/technicalArticles/javaserverpages/jsp_templates/)

IDE.

+3

, .

  • - , Mindmap , , .
  • IDE MVC, View JSP-. JSP .
  • Eclipse, .
  • - - Subversion, .
0
  • , JSP, .
  • jor .
  • Support him. No exceptions (if you need to, consider remaking the agreement).
  • To jump, try to capture the rendering phase and put the JSP file name in the expression as a comment. (maybe this can help Exec. JSP directly ... )
0
source

All Articles