2013年10月30日星期三

jsp in the include can include a servlet do ?

because I want to display a index.jsp in another right.jsp content , but right.jsp is necessary parameters , the parameter supplied by a servlet then turned right.jsp 's . So I would like to include in the index.jsp can be included in this servlet. But the investigation is still a lot of information can not be displayed .
Please expert guidance , do not just tell me the relative and absolute paths , which I have tried . I think I may want to use what method to get the path to the right !
Note: My index.jsp in the project of a new webroot folder . The servlet is in wen.xml

testServlet
/ testServlet

------ Solution ------------------------- -------------------
because I am one of the index.jsp right.jsp want to display the contents of another , but is necessary parameters right.jsp the parameters are determined by a servlet then turned right.jsp provided for .

according to your needs , and wants to include is impossible for inculde he was at compile time to do things , and you want to point to a servlet or a request for you this way index.jsp content can only be first , and then use ajax or iframe to load right.jsp



------ Solution ------------------------------------ --------
the parameter into session can not ?
------ Solution ---------------------------------------- ----
wrong path , jump servlet is entirely possible, jump to the servlet is to be written
<% = path%> / servletMapping ">


------ Solution ----------------------------- ---------------


generated jsp page top basePath Why not there .
------ Solution ---------------------------------------- ----
possible to use standard actions can also be dynamically included
------ Solution ---------------------- ----------------------

parameter passing


------ Solution ----------------------------- ---------------
可以用JSTL标签
<c:import url="你的url">
     <c:param name="值的名称(这边取什么 到另一个页面就用${名字}取得)" value="传入的值"/>
     <c:param name="值的名称(这边取什么 到另一个页面就用${名字}取得)" value="传入的值"/>
</c>

------ Solution ------------------- -------------------------
If the jsp <@ include is not with a label containing the servlet < jsp: include is possible
------ For reference only ------------------------------- --------

index
/ index.jsp

------ For reference only --------------------- ------------------

Will can say understand that okay ? I was a beginner , web.xml in jsp? How to use ?
------ For reference only -------------------------------------- -
  This reply was moderator deleted at 2011-08-18 11:59:49

------ For reference only ---------------------------------- -----
should be able to , and you have configured a servlet extension farewell missing
------ For reference only ------------- --------------------------

I added to the web.xml index.jsp , start tomcat on the web . xml error ! Looks like this method does not work ......
------ For reference only ------------------------------- --------


It stands to reason you usually access the servlet from the browser how to access , include the page in the same attribute can be written

according to your xml configuration , you are now in the browser address bar can not directly enter the servlet address access ?
------ For reference only -------------------------------------- -

I tried to write in the page "http://localhost:8080/sztz/testServlet" this is the address on a red wavy line ( I tried the myeclipse8.5), Tip is Fragment "http://localhost:8080/sztz/testServlet" was not found at expected path /
sztz / WebRoot / student / localhost: 8080/sztz/testServlet
Note : The above student is my webroot stored in the new folder the index.jsp .
------ For reference only ---------------------------------- -----
was not found at expected path /
sztz / WebRoot / student / localhost: 8080/sztz/testServlet

you wrong path bar, there is such a right, wrong , right
------ For reference only -------------------- -------------------
path is : request.getContextPath ();
------ For reference only - --------------------------------------
page = "sztz / testServlet" < br> ------ For reference only ---------------------------------------

sztz / WebRoot / student / localhost: 8080/sztz/testServlet
This is the error , I did not write this !
------ For reference only -------------------------------------- -

I tried, to no avail !
------ For reference only -------------------------------------- -
ah , so jump to the index even after the ah
------ For reference only ---------------------- -----------------

use your method , run the following error message :
org.apache.jasper.JasperException: / student / index.jsp (70,68) attribute for%> "is not properly terminated

------ For reference only ---------------------------------- -----

standard action ---- ?
dynamically included ---- ?
Can you give an example? It can also be used above me in ! Xianxie !

------ For reference only ---------------------------------- -----
Results posted today , I hope you help ......
------ For reference only ------------------ ---------------------
  This reply was moderator deleted at 2011-08-18 14:09:17

------ For reference only ---------------------------------- -----

this I understand is, the path is the problem , with a path, an error ! Check the information that the tag jsp: include the path is not a java code ! Therefore, the above said does not work with path way , which I also tried to !
------ For reference only -------------------------------------- -
good ! Results posted now ! Finally, I summarize .
1. concerning labeling jsp: include the page can not be used java code ( ie using <% = request.getContextPath ();%>) will complain (org.apache.jasper.JasperException ) .
2. use


The page 's value can not be a servlet. If you are using jsp param for passing parameters .
3. raise this issue for me , now I have two solution to the problem :
<1> use the session parameter passing
<2> will be included in a servlet content can also write a servlet, the servlet request of the steering parameters added to index.jsp, then the index.jsp the include contains right.jsp, while right.jsp above can be used in turn to the index.jsp parameters ( content involved here are : the use of jsp: include, you can use the page that contains the page to be included in the attribute parameter ) .
These are my personal summary , I hope that we can have the wrong kind . Thanks again for helping groups to answer the questions everyone . Maybe give to the less reasonable , hope you understand ! Thank you ......
------ For reference only ----------------------------------- ----
your summary is wrong, I use the 11 floor of the method is possible
------ For reference only ------------- --------------------------
Hello , can , in the servlet forwarding when not writing forward () method , like this:
request.getRequestDispatcher ("result.jsp"). include (arg0, arg1);

没有评论:

发表评论