Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to convert jspServet to jsp  RSS feed

 
Skumar Sanjeev
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

Please help to decode the jsp generated servlet back to JSP page.. some how all JSP page is deleted by mistake.. so please help to recover my jsp page from system generated...

Example:
package org.apache.jsp.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;

public final class login_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent {

private static java.util.List _jspx_dependants;

private org.apache.jasper.runtime.TagHandlerPool _005fjspx_005ftagPool_005fs_005fform_005fname_005faction;
private org.apache.jasper.runtime.TagHandlerPool _005fjspx_005ftagPool_005fs_005ftextfield_005fplaceholder_005fname_005fcssClass_005fnobody;
private org.apache.jasper.runtime.TagHandlerPool _005fjspx_005ftagPool_005fs_005fpassword_005fplaceholder_005fname_005fcssClass_005fnobody;
private org.apache.jasper.runtime.TagHandlerPool _005fjspx_005ftagPool_005fs_005fsubmit_005fvalue_005fvalidate_005ftype_005fcssClass_005fnobody;

public Object getDependants() {
return _jspx_dependants;
}

public void _jspInit() {
_005fjspx_005ftagPool_005fs_005fform_005fname_005faction = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
_005fjspx_005ftagPool_005fs_005ftextfield_005fplaceholder_005fname_005fcssClass_005fnobody = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
_005fjspx_005ftagPool_005fs_005fpassword_005fplaceholder_005fname_005fcssClass_005fnobody = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
_005fjspx_005ftagPool_005fs_005fsubmit_005fvalue_005fvalidate_005ftype_005fcssClass_005fnobody = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
}

public void _jspDestroy() {
_005fjspx_005ftagPool_005fs_005fform_005fname_005faction.release();
_005fjspx_005ftagPool_005fs_005ftextfield_005fplaceholder_005fname_005fcssClass_005fnobody.release();
_005fjspx_005ftagPool_005fs_005fpassword_005fplaceholder_005fname_005fcssClass_005fnobody.release();
_005fjspx_005ftagPool_005fs_005fsubmit_005fvalue_005fvalidate_005ftype_005fcssClass_005fnobody.release();
}

public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException {

JspFactory _jspxFactory = null;
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
PageContext _jspx_page_context = null;


try {
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html; charset=UTF-8");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;

out.write("\r\n");
out.write("\r\n");
out.write("\r\n");

String ContextPath = request.getContextPath();
ContextPath = request.getRequestURL().substring(0,request.getRequestURL().indexOf(ContextPath)) + ContextPath;
System.out.println(ContextPath);

out.write("\r\n");
out.write("\r\n");
out.write("<html>\r\n");
out.write("<head>\r\n");
out.write(" ");
org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "jq_include.jsp", out, false);
out.write("\r\n");
out.write("</head>\r\n");
out.write("<script type=\"text/javascript\">\r\n");
out.write("$(document).ready(function() {\r\n");
out.write(" $('input[type=\"submit\"]').attr('disabled','disabled');\r\n");
out.write(" $('input[type=\"text\"]').keyup(function() {\r\n");
out.write(" if($(this).val() != '') {\r\n");
out.write(" $('input[type=\"submit\"]').removeAttr('disabled');\r\n");
out.write(" }\r\n");
out.write(" });\r\n");
out.write(" });\r\n");
out.write("</script>\r\n");
out.write("<body style=\"background-image: url('");
out.print( ContextPath );
out.write("/jsp/images/homebackground_image.gif');\">\r\n");
out.write("<div class=\"container\">\r\n");
out.write("\t<div class=\"form-sign\">\r\n");
out.write("\t<table class=\"login-form\">\r\n");
out.write("\t\t<tr>\r\n");
out.write("\t\t\t<td>\r\n");
out.write("\t\t\t\t<h2 class=\"form-signin-heading\">Please sign in</h2>\t\r\n");
out.write("\t\t\t\t");
if (_jspx_meth_s_005fform_005f0(_jspx_page_context))
return;
out.write("\r\n");
out.write("\t\t\t</td>\r\n");
out.write("\t\t</tr>\r\n");
out.write("\t</table>\r\n");
out.write("\t</div>\r\n");
out.write("</div>\r\n");
out.write("</body>\r\n");
out.write("\r\n");
out.write("\r\n");
} catch (Throwable t) {
if (!(t instanceof SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
}
} finally {
if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
}
}

private boolean _jspx_meth_s_005fform_005f0(PageContext _jspx_page_context)
throws Throwable {
PageContext pageContext = _jspx_page_context;
JspWriter out = _jspx_page_context.getOut();
// s:form
org.apache.struts2.views.jsp.ui.FormTag _jspx_th_s_005fform_005f0 = (org.apache.struts2.views.jsp.ui.FormTag) _005fjspx_005ftagPool_005fs_005fform_005fname_005faction.get(org.apache.struts2.views.jsp.ui.FormTag.class);
_jspx_th_s_005fform_005f0.setPageContext(_jspx_page_context);
_jspx_th_s_005fform_005f0.setParent(null);
_jspx_th_s_005fform_005f0.setAction("/Details.action");
_jspx_th_s_005fform_005f0.setName("Details");
int _jspx_eval_s_005fform_005f0 = _jspx_th_s_005fform_005f0.doStartTag();
if (_jspx_eval_s_005fform_005f0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) {
if (_jspx_eval_s_005fform_005f0 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) {
out = _jspx_page_context.pushBody();
_jspx_th_s_005fform_005f0.setBodyContent((javax.servlet.jsp.tagext.BodyContent) out);
_jspx_th_s_005fform_005f0.doInitBody();
}
do {
out.write("\r\n");
out.write("\t\t\r\n");
out.write("\t\t\t\t\t");
if (_jspx_meth_s_005ftextfield_005f0(_jspx_th_s_005fform_005f0, _jspx_page_context))
return true;
out.write("\r\n");
out.write("\t\t\t\t\t");
if (_jspx_meth_s_005fpassword_005f0(_jspx_th_s_005fform_005f0, _jspx_page_context))
return true;
out.write("\r\n");
out.write("\t\t\t\t\t");
if (_jspx_meth_s_005fsubmit_005f0(_jspx_th_s_005fform_005f0, _jspx_page_context))
return true;
out.write("\r\n");
out.write("\t\t\t\t");
int evalDoAfterBody = _jspx_th_s_005fform_005f0.doAfterBody();
if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN)
break;
} while (true);
if (_jspx_eval_s_005fform_005f0 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) {
out = _jspx_page_context.popBody();
}
}
if (_jspx_th_s_005fform_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
_005fjspx_005ftagPool_005fs_005fform_005fname_005faction.reuse(_jspx_th_s_005fform_005f0);
return true;
}
_005fjspx_005ftagPool_005fs_005fform_005fname_005faction.reuse(_jspx_th_s_005fform_005f0);
return false;
}

private boolean _jspx_meth_s_005ftextfield_005f0(javax.servlet.jsp.tagext.JspTag _jspx_th_s_005fform_005f0, PageContext _jspx_page_context)
throws Throwable {
PageContext pageContext = _jspx_page_context;
JspWriter out = _jspx_page_context.getOut();
// s:textfield
org.apache.struts2.views.jsp.ui.TextFieldTag _jspx_th_s_005ftextfield_005f0 = (org.apache.struts2.views.jsp.ui.TextFieldTag) _005fjspx_005ftagPool_005fs_005ftextfield_005fplaceholder_005fname_005fcssClass_005fnobody.get(org.apache.struts2.views.jsp.ui.TextFieldTag.class);
_jspx_th_s_005ftextfield_005f0.setPageContext(_jspx_page_context);
_jspx_th_s_005ftextfield_005f0.setParent((javax.servlet.jsp.tagext.Tag) _jspx_th_s_005fform_005f0);
_jspx_th_s_005ftextfield_005f0.setCssClass("input-block-level");
_jspx_th_s_005ftextfield_005f0.setName("username");
_jspx_th_s_005ftextfield_005f0.setDynamicAttribute(null, "placeholder", new String("Username"));
int _jspx_eval_s_005ftextfield_005f0 = _jspx_th_s_005ftextfield_005f0.doStartTag();
if (_jspx_th_s_005ftextfield_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
_005fjspx_005ftagPool_005fs_005ftextfield_005fplaceholder_005fname_005fcssClass_005fnobody.reuse(_jspx_th_s_005ftextfield_005f0);
return true;
}
_005fjspx_005ftagPool_005fs_005ftextfield_005fplaceholder_005fname_005fcssClass_005fnobody.reuse(_jspx_th_s_005ftextfield_005f0);
return false;
}

private boolean _jspx_meth_s_005fpassword_005f0(javax.servlet.jsp.tagext.JspTag _jspx_th_s_005fform_005f0, PageContext _jspx_page_context)
throws Throwable {
PageContext pageContext = _jspx_page_context;
JspWriter out = _jspx_page_context.getOut();
// s:password
org.apache.struts2.views.jsp.ui.PasswordTag _jspx_th_s_005fpassword_005f0 = (org.apache.struts2.views.jsp.ui.PasswordTag) _005fjspx_005ftagPool_005fs_005fpassword_005fplaceholder_005fname_005fcssClass_005fnobody.get(org.apache.struts2.views.jsp.ui.PasswordTag.class);
_jspx_th_s_005fpassword_005f0.setPageContext(_jspx_page_context);
_jspx_th_s_005fpassword_005f0.setParent((javax.servlet.jsp.tagext.Tag) _jspx_th_s_005fform_005f0);
_jspx_th_s_005fpassword_005f0.setCssClass("input-block-level");
_jspx_th_s_005fpassword_005f0.setName("password");
_jspx_th_s_005fpassword_005f0.setDynamicAttribute(null, "placeholder", new String("Password"));
int _jspx_eval_s_005fpassword_005f0 = _jspx_th_s_005fpassword_005f0.doStartTag();
if (_jspx_th_s_005fpassword_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
_005fjspx_005ftagPool_005fs_005fpassword_005fplaceholder_005fname_005fcssClass_005fnobody.reuse(_jspx_th_s_005fpassword_005f0);
return true;
}
_005fjspx_005ftagPool_005fs_005fpassword_005fplaceholder_005fname_005fcssClass_005fnobody.reuse(_jspx_th_s_005fpassword_005f0);
return false;
}

private boolean _jspx_meth_s_005fsubmit_005f0(javax.servlet.jsp.tagext.JspTag _jspx_th_s_005fform_005f0, PageContext _jspx_page_context)
throws Throwable {
PageContext pageContext = _jspx_page_context;
JspWriter out = _jspx_page_context.getOut();
// s:submit
org.apache.struts2.views.jsp.ui.SubmitTag _jspx_th_s_005fsubmit_005f0 = (org.apache.struts2.views.jsp.ui.SubmitTag) _005fjspx_005ftagPool_005fs_005fsubmit_005fvalue_005fvalidate_005ftype_005fcssClass_005fnobody.get(org.apache.struts2.views.jsp.ui.SubmitTag.class);
_jspx_th_s_005fsubmit_005f0.setPageContext(_jspx_page_context);
_jspx_th_s_005fsubmit_005f0.setParent((javax.servlet.jsp.tagext.Tag) _jspx_th_s_005fform_005f0);
_jspx_th_s_005fsubmit_005f0.setValue("Sign in");
_jspx_th_s_005fsubmit_005f0.setDynamicAttribute(null, "validate", new String("true"));
_jspx_th_s_005fsubmit_005f0.setType("button");
_jspx_th_s_005fsubmit_005f0.setCssClass("btn btn-lg btn-primary btn-block");
int _jspx_eval_s_005fsubmit_005f0 = _jspx_th_s_005fsubmit_005f0.doStartTag();
if (_jspx_th_s_005fsubmit_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
_005fjspx_005ftagPool_005fs_005fsubmit_005fvalue_005fvalidate_005ftype_005fcssClass_005fnobody.reuse(_jspx_th_s_005fsubmit_005f0);
return true;
}
_005fjspx_005ftagPool_005fs_005fsubmit_005fvalue_005fvalidate_005ftype_005fcssClass_005fnobody.reuse(_jspx_th_s_005fsubmit_005f0);
return false;
}
}

 
Tim Cooke
Marshal
Posts: 3835
221
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh wow, what a mistake to make!! I don't know of any way to recover a jsp from the generated Java code. Perhaps there's some tool out there that might help you, but I don't know of any.

I would start by checking your filesystem to see if there's a copy hanging around there, in some sort of .Trash folder or something. Otherwise revert back to the latest in your source repository system and redo the last bit of work you were doing. You are using a source repository system aren't you? If not, now might be a good time to start.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And backups? You need to be continually backing up your systems.

There is no tool to recreate a JSP from its translated source. If you cannot recover the files from a backup or source control you'll need to reverse engineer the pages by hand.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!