%@ page import="org.apache.log4j.*" %> <%@ page import="com.ecyrd.jspwiki.*" %> <%@ page import="java.util.Calendar,java.util.Date" %> <%! public void jspInit() { wiki = WikiEngine.getInstance( getServletConfig() ); } Category log = Category.getInstance("JSPWiki"); WikiEngine wiki; %> <% String pagereq = wiki.safeGetParameter( request, "page" ); if( pagereq == null ) { throw new ServletException("No page defined"); } NDC.push( wiki.getApplicationName()+":"+pagereq ); String pageurl = wiki.encodeName( pagereq ); String action = request.getParameter("action"); // // Set the response type before we branch. // response.setContentType("text/html; charset="+wiki.getContentEncoding() ); log.debug("Request character encoding="+request.getCharacterEncoding()); log.debug("Request content type+"+request.getContentType()); if( action != null && action.equals("save") ) { log.info("Saving page "+pagereq+". User="+request.getRemoteUser()+", host="+request.getRemoteHost() ); // FIXME: I am not entirely sure if the JSP page is the // best place to check for concurrent changes. It certainly // is the best place to show errors, though. long pagedate = Long.parseLong(request.getParameter("edittime")); Date change = wiki.pageLastChanged( pagereq ); if( change != null && change.getTime() != pagedate ) { // // Someone changed the page while we were editing it! // log.info("Page changed, warning user."); pageContext.forward( "PageModified.jsp" ); return; } wiki.saveText( pagereq, wiki.safeGetParameter( request, "text" ), request ); response.sendRedirect("Wiki.jsp?page="+pageurl); return; } log.info("Editing page "+pagereq+". User="+request.getRemoteUser()+", host="+request.getRemoteHost() ); // // If the page does not exist, we'll get a null here. // long lastchange = 0; Date d = wiki.pageLastChanged( pagereq ); if( d != null ) lastchange = d.getTime(); %>
<%@ include file="LeftMenu.jsp" %> <%@ include file="LeftMenuFooter.jsp" %> |
Edit page <%=pagereq%> |