JSP import with dynamic URL

时间:2015-05-08 10:02:38

标签: java jsp

I am in a situation where I am importing a jsp page which in turn imports two other pages based on the parameters of the import. The problem is that when I try to use the parameters in the URL of the two imports on the page that is imported, it is an invalid URL. But if I hard code the parameters into the URL it loads with no problem. This is how my code is:

class TAggregateKey
{
    int id {get; set;}
    byte sequence {get; set;}
}

Am I outputting the parameters incorrectly? It doesn't work even if I hard code the variables like:

TAggregate a = new Agreggate(value, value, value);
TAggregateKey id = repositoryA.Add(a);    //TAggregateKey Add(TAggregate a)
repositoryB.DoSomething(id, value);      //void DoSomething(TAggregateKey id, int value)

It will only work if I actually write 3 in the c:import like this:

//the following is the first import
<c:import url="/blahblah/index.jsp">
    <c:param name="sectionId" value="3" />
    <c:param name="aPageId" value="5" />
    <c:param name="bPageId" value="2" />
</c:import>

// the following is (index.jsp) the page that is imported and imports other pages based on the parameters

    int sectionId = request.getParameter("sectionId");
    int aPageId = request.getParameter("aPageId");
    int bPageId = request.getParameter("bPageId");

    <c:import url="/blahblah/blah.jsp?sectionId=<%=sectionId%>&page_id=<%=aPageId%>" />

    <c:import url="/blahblah/blah.jsp?sectionId=<%=sectionId%>&page_id=<%=bPageId%>" />

0 个答案:

没有答案