Hey GUys,

im trying to include a file inside my template.

My code:

String get_act = null;
            get_act = request.getParameter("act");


            boolean loggedin = (session.getAttribute("logginname") != null) ? true : false;
            
            if( loggedin == false && get_act != "login"){
                out.write("Redirecting<br>");
                response.sendRedirect("?act=login");
            }else{
                String include_page = null;
                include_page = get_act +".jsp";


                %>
                <jsp:include page=include_page></jsp:include>
                <%


            }

So what im trying to do is this:

when i go to index.jsp?act=overview i want to include overview.jsp , when im going to index.jsp?act=logout i want to include logout.jsp

Do you guys know what is wrong or do you know an other method?

It looks like i cant get the include_page variable inside the jsp_include tag?

Thx

Hey guys, im still trying, but im using some other method, my code :

if( loggedin == false &&
                        (get_act==null || !get_act.equals(new String("login")))
                ){
                    response.sendRedirect("index.jsp?act=login");
                }else{
                    if(get_act.equals(new String("login"))){
                        out.print("login");
                    }else{
                        %><jsp:include page='homepage.jsp'></jsp:include><%
                    }

                }

but the problem is... i cant include a file... so when i include the file like this:
<jsp:include page='homepage.jsp'></jsp:include>

i get the following error:

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: java.lang.NullPointerException
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:402)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:470)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:364)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
root cause

java.lang.NullPointerException
	org.apache.jsp.index_jsp._jspService(index_jsp.java from :82)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:93)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:470)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:364)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)

could you please help me?

THx!

EDIT: the homepage.jsp file only includes some html (for now)

Before go to this step,
if( loggedin == false && get_act != "login"){

check get_act for null, and see whether it is going to be fine
if (get_act != null){
===
===

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.