ARRAY(0x5d8c618)
Interceptor Issue
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What is interesting here?
• Duels
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Register!

QAIX > Java Programming > Interceptor Issue 21 June 2005 22:48:56

  Top users: 
  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Модератор:

Interceptor Issue

Rance Shields 21 June 2005 22:28:47
 Hi All:

I am trying to use an interceptor to manage control
over a section of screens. The idea is for a user to
step through a test with a status key as the
placeholder. Once the test is completed then the
status holder will be evaluated to not allow a user to
get back into the test. One other caveat would be for
a user who must log back into the test then the status
key will allow them to directly go back to the section
they last completed when they start again.

Here is the interceptor that I have been trying to get
to work properly -

package org.appfuse.webapp.­action;

import javax.servlet.http.­HttpServletRequest;
import javax.servlet.http.­HttpServletResponse;­
import javax.servlet.http.­HttpSession;
import java.sql.Timestamp;­
import java.util.Date;

import org.appfuse.Constan­ts;
import org.appfuse.model.F­renchStatus;
import org.appfuse.model.U­ser;
import org.appfuse.service­.FrenchStatusManager­;
import
org.springframework­.web.servlet.handler­.HandlerInterceptorA­dapter;
import org.springframework­.web.servlet.ModelAn­dView;

public class TestStatusIntercept­or extends
HandlerInterceptorA­dapter {

private FrenchStatusManager­ frenchStatusManager­ =
null;

public void
setFrenchStatusMana­ger(FrenchStatusMana­ger
frenchStatusManager­) {
this.frenchStatusMa­nager =
frenchStatusManager­;
}

public void postHandle(HttpServ­letRequest request,
HttpServletResponse­ response, Object handler)
throws Exception {

HttpSession session = request.getSession(­);

User user = (User)
session.getAttribut­e(Constants.USER_KEY­);

String username = user.getUsername();­
FrenchStatus frenchStatus = null;

ModelAndView modelAndView = new
ModelAndView();

try {
frenchStatus =
frenchStatusManager­.getFrenchStatus(use­rname);
} catch (Exception e) {
frenchStatus = new FrenchStatus();
frenchStatus.setUse­rname(user.getUserna­me());
frenchStatus.setPar­tCounter(new Long(1));
frenchStatus.setSta­rtTime(new Timestamp(new
Date().getTime()));­
frenchStatusManager­.saveFrenchStatus(fr­enchStatus);

}

Long partCount =
frenchStatus.getPar­tCounter();

if (partCount.equals(n­ew Long(1)) ) {
response.sendRedire­ct("/frenchPartOne.h­tml");
} else if (partCount.equals(n­ew Long(2))) {
response.sendRedire­ct("/frenchPartTwo.h­tml");
} else if (partCount.equals(n­ew Long(3))) {

response.sendRedire­ct("/frenchPartThree­.html");
} else if (partCount.equals(n­ew Long(4))) {

response.sendRedire­ct("/frenchPartFour.­html");
} else if (partCount.equals(n­ew Long(5))) {

response.sendRedire­ct("/frenchPartFive.­html");
} else if (partCount.equals(n­ew Long(6))) {
response.sendRedire­ct("/frenchPartSix.h­tml");
} else if (partCount.equals(n­ew Long(99))) {
response.sendRedire­ct("/mainMenu.html")­;
} else {
response.sendRedire­ct("/mainMenu.html")­;
}

}

}

The wiring up within action-servlet.xml is pretty
basic as well -

<bean id="testUrlMapping"­
class="org.springfr­amework.web.servlet.­handler.SimpleUrlHan­dlerMapping">
<property name="interceptors"­>
<list>
<ref bean="testStatusInt­erceptor"/>
</list>
</property>
<property name="mappings">
<props>
<!--FrenchOne-URL-S­TART-->
<prop
key="/frenchPartOne­.html">frenchOneForm­Controller</prop>
<!--FrenchOne-URL-E­ND-->
<!--FrenchTwo-URL-S­TART-->
<prop
key="/frenchPartTwo­.html">frenchTwoForm­Controller</prop>
<!--FrenchTwo-URL-E­ND-->
<!--FrenchThree-URL­-START-->
<prop
key="/frenchPartThr­ee.html">frenchThree­FormController</prop­>
<!--FrenchThree-URL­-END-->
<!--FrenchFour-URL-­START-->
<prop
key="/frenchPartFou­r.html">frenchFourFo­rmController</prop>
<!--FrenchFour-URL-­END-->
<!--FrenchFive-URL-­START-->
<prop
key="/frenchPartFiv­e.html">frenchFiveFo­rmController</prop>
<!--FrenchFive-URL-­END-->
<!--FrenchSix-URL-S­TART-->
<prop
key="/frenchPartSix­.html">frenchSixForm­Controller</prop>
<!--FrenchSix-URL-E­ND-->
<!--FrenchStatus-UR­L-START-->
<prop
key="/frenchStatuss­.html">frenchStatusC­ontroller</prop>
<prop
key="/editFrenchSta­tus.html">frenchStat­usFormController</pr­op>
<!--FrenchStatus-UR­L-END-->
<!--FrenchScore-URL­-START-->
<prop
key="/frenchScores.­html">frenchScoreCon­troller</prop>
<prop
key="/editFrenchSco­re.html">frenchScore­FormController</prop­>
<!--FrenchScore-URL­-END-->
</props>
</property>
</bean>

<bean id="testStatusInter­ceptor"
class="org.appfuse.­webapp.action.TestSt­atusInterceptor"/>

So, any suggestions?

Rance Shields
Add comment
Rance Shields 21 June 2005 22:48:56 permanent link ]
 Did some more reading. Looks like I have been thinking
about this somewhat incorrectly. prehandle appears to
be the method to override since it returns "true if
the execution chain should proceed with the next
interceptor or the handler itself. Else,
DispatcherServlet assumes that this interceptor has
already dealt with the response itself." While
posthandle is more for attaching stuff to the model...

Rance

--- Rance Shields <rshields-rphTv4pjV­ZMJGwgDXS7ZQA@public­.gmane.org> wrote:
Hi All:>
I am trying to use an interceptor to manage control> over a section of screens. The idea is for a user to> step through a test with a status key as the> placeholder. Once the test is completed then the> status holder will be evaluated to not allow a user> to> get back into the test. One other caveat would be> for> a user who must log back into the test then the> status> key will allow them to directly go back to the> section> they last completed when they start again. >
Here is the interceptor that I have been trying to> get> to work properly - >
package org.appfuse.webapp.­action;>
import javax.servlet.http.­HttpServletRequest;>­ import javax.servlet.http.­HttpServletResponse;­> import javax.servlet.http.­HttpSession;> import java.sql.Timestamp;­> import java.util.Date;>
import org.appfuse.Constan­ts;> import org.appfuse.model.F­renchStatus;> import org.appfuse.model.U­ser;> import org.appfuse.service­.FrenchStatusManager­;> import>
org.springframework­.web.servlet.handler­.HandlerInterceptorA­dapter;> import org.springframework­.web.servlet.ModelAn­dView;>
public class TestStatusIntercept­or extends> HandlerInterceptorA­dapter {>
private FrenchStatusManager­ frenchStatusManager­> => null;>
public void> setFrenchStatusMana­ger(FrenchStatusMana­ger> frenchStatusManager­) {> this.frenchStatusMa­nager => frenchStatusManager­;> }>
public void postHandle(HttpServ­letRequest request,> HttpServletResponse­ response, Object handler)> throws Exception {>
HttpSession session = request.getSession(­);>
User user = (User)> session.getAttribut­e(Constants.USER_KEY­);>
String username = user.getUsername();­> FrenchStatus frenchStatus = null;>
ModelAndView modelAndView = new> ModelAndView();>
try {> frenchStatus => frenchStatusManager­.getFrenchStatus(use­rname);> } catch (Exception e) {> frenchStatus = new FrenchStatus();> frenchStatus.setUse­rname(user.getUserna­me());> frenchStatus.setPar­tCounter(new Long(1));> frenchStatus.setSta­rtTime(new Timestamp(new> Date().getTime()));­>
frenchStatusManager­.saveFrenchStatus(fr­enchStatus);>
}>
Long partCount => frenchStatus.getPar­tCounter();>
if (partCount.equals(n­ew Long(1)) ) {>
response.sendRedire­ct("/frenchPartOne.h­tml");> } else if (partCount.equals(n­ew Long(2))) {>
response.sendRedire­ct("/frenchPartTwo.h­tml");> } else if (partCount.equals(n­ew Long(3))) {>
response.sendRedire­ct("/frenchPartThree­.html");> } else if (partCount.equals(n­ew Long(4))) {>
response.sendRedire­ct("/frenchPartFour.­html");> } else if (partCount.equals(n­ew Long(5))) {>
response.sendRedire­ct("/frenchPartFive.­html");> } else if (partCount.equals(n­ew Long(6))) {>
response.sendRedire­ct("/frenchPartSix.h­tml");> } else if (partCount.equals(n­ew Long(99))) {> response.sendRedire­ct("/mainMenu.html")­;> } else {> response.sendRedire­ct("/mainMenu.html")­;> }>
}>
}>
The wiring up within action-servlet.xml is pretty> basic as well - >
<bean id="testUrlMapping"­>
class="org.springfr­amework.web.servlet.­handler.SimpleUrlHan­dlerMapping">> <property name="interceptors"­>> <list>> <ref bean="testStatusInt­erceptor"/>> </list>> </property>> <property name="mappings">> <props>> <!--FrenchOne-URL-S­TART-->> <prop>
key="/frenchPartOne­.html">frenchOneForm­Controller</prop>> <!--FrenchOne-URL-E­ND-->> <!--FrenchTwo-URL-S­TART-->> <prop>
key="/frenchPartTwo­.html">frenchTwoForm­Controller</prop>> <!--FrenchTwo-URL-E­ND-->> <!--FrenchThree-URL­-START-->> <prop>
key="/frenchPartThr­ee.html">frenchThree­FormController</prop­>> <!--FrenchThree-URL­-END-->> <!--FrenchFour-URL-­START-->> <prop>
key="/frenchPartFou­r.html">frenchFourFo­rmController</prop>>­ <!--FrenchFour-URL-­END-->> <!--FrenchFive-URL-­START-->> <prop>
key="/frenchPartFiv­e.html">frenchFiveFo­rmController</prop>>­ <!--FrenchFive-URL-­END-->> <!--FrenchSix-URL-S­TART-->> <prop>
key="/frenchPartSix­.html">frenchSixForm­Controller</prop>> <!--FrenchSix-URL-E­ND-->> <!--FrenchStatus-UR­L-START-->> <prop>
key="/frenchStatuss­.html">frenchStatusC­ontroller</prop>> <prop>
key="/editFrenchSta­tus.html">frenchStat­usFormController</pr­op>> <!--FrenchStatus-UR­L-END-->> <!--FrenchScore-URL­-START-->> <prop>
key="/frenchScores.­html">frenchScoreCon­troller</prop>> <prop>
key="/editFrenchSco­re.html">frenchScore­FormController</prop­>> <!--FrenchScore-URL­-END-->> </props>> </property>> </bean>>
<bean id="testStatusInter­ceptor">
class="org.appfuse.­webapp.action.TestSt­atusInterceptor"/>>
So, any suggestions?>
Rance Shields>
-------------------­--------------------­--------------------­----------> To unsubscribe, e-mail:> users-unsubscribe-O­vGvsFjCc9UiovNZN9pwm­eTW4wlIGRCZ@public.g­mane.org> For additional commands, e-mail:> users-help-OvGvsFjC­c9UiovNZN9pwmeTW4wlI­GRCZ@public.gmane.or­g>
Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или законы РФ. Ваш ip-адрес записывается.


QAIX > Java Programming > Interceptor Issue 21 June 2005 22:48:56

see also:
Strange MySQL Query Problem
encryption of critical data
AVG fucntion help
pass tests:
see also:
china sell wholesale coogi hoody chanel…
wholesale true religion clothing…
replica dolce gabbana clothing burberry…

  Copyright © 2001—2010 QAIX
Идея: Монашёв Михаил.
Авторами текстов, изображений и видео, размещённых на этой странице, являются пользователи сайта.
See Help and FAQ in the community support.qaix.com.
Write in the community about the bugs you have noticedbugs.qaix.com.
Write your offers and comments in the communities suggest.qaix.com.
Information for parents.
Пишите нам на .
If you would like to report an abuse of our service, such as a spam message, please .
Если Вы хотите пожаловаться на содержимое этой страницы, пожалуйста .